[MIG] pos_usability to v14
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
# Copyright 2014-2021 Akretion France (http://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "POS Usability",
|
"name": "POS Usability",
|
||||||
"version": "12.0.1.0.0",
|
"version": "14.0.1.0.0",
|
||||||
"category": "Point of sale",
|
"category": "Point of sale",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Misc usability improvement for point of sale",
|
"summary": "Misc usability improvement for point of sale",
|
||||||
@@ -24,6 +26,10 @@ Akretion:
|
|||||||
"author": "Akretion",
|
"author": "Akretion",
|
||||||
"website": "http://www.akretion.com",
|
"website": "http://www.akretion.com",
|
||||||
"depends": ["point_of_sale"],
|
"depends": ["point_of_sale"],
|
||||||
"data": ["report/pos.xml"],
|
"data": [
|
||||||
"installable": False,
|
"report/pos.xml",
|
||||||
|
"views/pos_category.xml",
|
||||||
|
"views/product.xml",
|
||||||
|
],
|
||||||
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|||||||
2
pos_usability/models/__init__.py
Normal file
2
pos_usability/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
from . import product
|
||||||
|
from . import pos_category
|
||||||
25
pos_usability/models/pos_category.py
Normal file
25
pos_usability/models/pos_category.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class PosCategory(models.Model):
|
||||||
|
_inherit = 'pos.category'
|
||||||
|
|
||||||
|
product_count = fields.Integer(
|
||||||
|
'# Products', compute='_compute_product_count',
|
||||||
|
help="The number of products under this point of sale category "
|
||||||
|
"(does not consider the children categories)")
|
||||||
|
|
||||||
|
# inspired by the code of odoo/addons/product/models/product.py
|
||||||
|
def _compute_product_count(self):
|
||||||
|
read_group_res = self.env['product.template'].read_group(
|
||||||
|
[('pos_categ_id', 'in', self.ids)],
|
||||||
|
['pos_categ_id'], ['pos_categ_id'])
|
||||||
|
group_data = dict(
|
||||||
|
(data['pos_categ_id'][0], data['pos_categ_id_count']) for data
|
||||||
|
in read_group_res)
|
||||||
|
for pos_categ in self:
|
||||||
|
pos_categ.product_count = group_data.get(pos_categ.id, 0)
|
||||||
12
pos_usability/models/product.py
Normal file
12
pos_usability/models/product.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Copyright 2017-2021 Akretion France (http://www.akretion.com/)
|
||||||
|
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
available_in_pos = fields.Boolean(tracking=True)
|
||||||
|
pos_categ_id = fields.Many2one(tracking=True)
|
||||||
35
pos_usability/views/pos_category.xml
Normal file
35
pos_usability/views/pos_category.xml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2015-2021 Akretion France (http://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="product_pos_category_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">pos_usability.pos.category.form</field>
|
||||||
|
<field name="model">pos.category</field>
|
||||||
|
<field name="inherit_id" ref="point_of_sale.product_pos_category_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<div class="oe_title" position="before">
|
||||||
|
<div class="oe_button_box" name="button_box">
|
||||||
|
<button class="oe_stat_button"
|
||||||
|
name="%(product.product_template_action_all)d"
|
||||||
|
icon="fa-th-list"
|
||||||
|
type="action"
|
||||||
|
context="{'search_default_pos_categ_id': active_id}">
|
||||||
|
<div class="o_form_field o_stat_info">
|
||||||
|
<span class="o_stat_value"><field name="product_count"/></span>
|
||||||
|
<span class="o_stat_text"> Products</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
43
pos_usability/views/product.xml
Normal file
43
pos_usability/views/product.xml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2015-2021 Akretion France (http://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- put option "available in POS" at the top of product form view -->
|
||||||
|
<record id="product_template_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">usability.pos.product.template</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="point_of_sale.product_template_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group[@name='pos']//field[@name='available_in_pos']" position="replace"/>
|
||||||
|
<xpath expr="//div[@name='options']//field[@name='sale_ok']/.." position="after">
|
||||||
|
<div name="available_in_pos">
|
||||||
|
<field name="available_in_pos"/>
|
||||||
|
<label for="available_in_pos"/>
|
||||||
|
</div>
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_template_search_view" model="ir.ui.view">
|
||||||
|
<field name="name">pos_usability.product.template.search</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="product.product_template_search_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="categ_id" position="after">
|
||||||
|
<field name="pos_categ_id" filter_domain="[('pos_categ_id', 'child_of', raw_value)]"/>
|
||||||
|
</field>
|
||||||
|
<filter name="categ_id" position="after">
|
||||||
|
<filter name="pos_categ_groupby" string="Point of Sale Category" context="{'group_by': 'pos_categ_id'}"/>
|
||||||
|
</filter>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user