Browse Source

[8.0] [IMP] pos_pricelist: Only retrieve the pricelists that are needed and not all (#260)

* [ADD] Filter pricelist by pos

* [MOD] Send the pos_config_id by context

* [MOD] Domain in js instead of query in search_read

* [FIX] Pylint details
pull/106/merge
ssaid 7 years ago
committed by Rafael Blasco
parent
commit
b294fd2540
  1. 13
      pos_pricelist/models/pos_pricelist.py
  2. 24
      pos_pricelist/static/src/js/models.js
  3. 25
      pos_pricelist/views/pos_pricelist_views.xml

13
pos_pricelist/models/pos_pricelist.py

@ -18,6 +18,10 @@
##############################################################################
from openerp import models, fields
import logging
logger = logging.getLogger(__name__)
class PosPriceListConfig(models.Model):
_inherit = 'pos.config'
@ -26,3 +30,12 @@ class PosPriceListConfig(models.Model):
string='Price With Taxes',
help="Display Prices with taxes on POS"
)
class product_pricelist(models.Model):
_inherit = 'product.pricelist'
pos_config_ids = fields.Many2many(
'pos.config', 'pricelist_posconfig_rel',
'pricelist_id', 'pos_id', string='PoS',
help='if empty will be available for all the pos')

24
pos_pricelist/static/src/js/models.js

@ -725,11 +725,17 @@ function pos_pricelist_models(instance, module) {
'name',
'version_id',
'currency_id'],
domain: function () {
domain: function (self) {
return [
['type', '=', 'sale']
'|',
'|',
['id', '=', self.config.pricelist_id[0]],
['pos_config_ids', '=', false],
['pos_config_ids', 'in', [self.config.id]],
['type', '=', 'sale'],
]
},
context: function(self){ return { pos_config_id: self.config.id }; },
loaded: function (self, pricelists) {
self.db.add_pricelists(pricelists);
}
@ -741,7 +747,12 @@ function pos_pricelist_models(instance, module) {
'date_start',
'date_end',
'items'],
domain: null,
domain: function (self) {
var pricelist_ids = _.map(_.keys(self.db.pricelist_by_id), function(el){return parseInt(el)});
return [
['pricelist_id', 'in', pricelist_ids]
]
},
loaded: function (self, versions) {
self.db.add_pricelist_versions(versions);
}
@ -763,7 +774,12 @@ function pos_pricelist_models(instance, module) {
'product_tmpl_id',
'sequence'
],
domain: null,
domain: function (self) {
var version_ids = _.map(_.keys(self.db.pricelist_version_by_id), function (el){return parseInt(el);});
return [
['price_version_id', 'in', version_ids]
];
},
loaded: function (self, items) {
self.db.add_pricelist_items(items);
}

25
pos_pricelist/views/pos_pricelist_views.xml

@ -11,5 +11,30 @@
</field>
</field>
</record>
<record id="view_product_pricelist_form_inherit_pos" model="ir.ui.view">
<field name="name">product.pricelist.form.inherit.pos</field>
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='type']" position="after">
<field name="pos_config_ids" attrs="{'invisible': [('type','!=','sale')]}" widget="many2many_tags"/>
</xpath>
</data>
</field>
</record>
<record id="view_product_pricelist_tree_inherit_pos" model="ir.ui.view">
<field name="name">product.pricelist.tree.inherit.pos</field>
<field name="model">product.pricelist</field>
<field name="inherit_id" ref="product.product_pricelist_view_tree"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='type']" position="after">
<field name="pos_config_ids" widget="many2many_tags"/>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save