Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
[FIX] flake8;
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Jan 19, 2015
1 parent 4e66378 commit 6193837
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 40 deletions.
21 changes: 11 additions & 10 deletions integrated_trade_product/model/product_integrated_trade_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class product_integrated_trade_catalog(Model):
_auto = False
_table = 'product_integrated_trade_catalog'



# Overloadable Section
def prepare_product_supplierinfo(
self, cr, uid, supplier_partner_id, supplier_product_id,
Expand Down Expand Up @@ -74,9 +72,11 @@ def update_product(
psi_obj = self.pool['product.supplierinfo']
for pitc in self.browse(cr, uid, ids, context=context):
if pitc.hidden_product_tmpl_id.id:
psi_ids = psi_obj.search(cr, uid, [
('supplier_product_id', '=', pitc.supplier_product_id),
], context=context)
psi_ids = psi_obj.search(
cr, uid, [
('supplier_product_id', '=', pitc.supplier_product_id),
], context=context)
psi_ids = psi_ids
# psi_obj.unlink(
# cr, uid, [pitc.hidden_supplierinfo_id.id],
# context=context)
Expand All @@ -98,8 +98,9 @@ def _link_product(
def _unlink_supplier_product(
self, cr, uid, supplier_product_ids, context=None):
psi_obj = self.pool['product.supplierinfo']
res = psi_obj.search(cr, uid, [
('supplier_product_id', 'in', supplier_product_ids),
res = psi_obj.search(
cr, uid, [
('supplier_product_id', 'in', supplier_product_ids),
], context=context)
psi_lst = psi_obj.browse(cr, uid, res, context=context)
product_tmpl_ids = [x.product_id.id for x in psi_lst]
Expand Down Expand Up @@ -159,9 +160,9 @@ def _set_product_tmpl_id(
'Supplier Partner Name', readonly=True),
'hidden_product_tmpl_id': fields.many2one(
'product.template', 'Product (Technical Field)', readonly=True),
# 'hidden_supplierinfo_id': fields.many2one(
# 'product.suppplierinfo', 'SupplierInfo (Technical Field)',
# readonly=True),
# 'hidden_supplierinfo_id': fields.many2one(
# 'product.suppplierinfo', 'SupplierInfo (Technical Field)',
# readonly=True),
'supplier_product_id': fields.many2one(
'product.product', 'Supplier Product', readonly=True),
'supplier_company_id': fields.many2one(
Expand Down
17 changes: 8 additions & 9 deletions integrated_trade_product/model/product_pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from openerp.osv.orm import Model
from openerp.addons import decimal_precision as dp


class product_supplierinfo(Model):
_inherit = 'product.supplierinfo'

Expand All @@ -37,19 +38,17 @@ def _get_integrated_price(
res[psi.id] = 0
return res


_columns = {
'integrated_price': fields.function(
_get_integrated_price, string='Unit Price',
digits_compute=dp.get_precision('Integrated Product Price'),
store={
'product.supplierinfo': (
lambda self, cr, uid, ids, context=None: ids,
[
'supplier_product_id',
'pricelist_ids',
], 10)}),
store={'product.supplierinfo': (
lambda self, cr, uid, ids, context=None: ids,
[
'supplier_product_id',
'pricelist_ids',
], 10)}),
'supplier_product_id': fields.many2one(
'product.product',
'Product in the Supplier Catalog', selected=True),
}
}
11 changes: 5 additions & 6 deletions integrated_trade_product/model/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#
##############################################################################

from openerp import SUPERUSER_ID
from openerp.osv import fields
from openerp.osv.orm import Model


Expand All @@ -30,8 +28,8 @@ class product_product(Model):

_INTEGRATED_FIELDS = [
'name', 'default_code', 'lst_price', 'price', 'price_extra',
'pricelist_id', # ?
'price_margin', # ?
# 'pricelist_id', # ?
# 'price_margin', # ?
'taxes_id',
'list_price',
]
Expand All @@ -42,8 +40,9 @@ def write(self, cr, uid, ids, vals, context=None):
# Update product in customer database if required
if list(set(vals.keys()) & set(self._INTEGRATED_FIELDS)):
pitc_obj = self.pool['product.integrated.trade.catalog']
pitc_ids = pitc_obj.search(cr, uid,
pitc_ids = pitc_obj.search(
cr, uid,
[('supplier_product_id', 'in', ids)], context=context)

pitc_obj.update_product(cr, uid, pitc_ids, context=context)
return res
17 changes: 8 additions & 9 deletions integrated_trade_product/model/product_supplierinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from openerp.osv.orm import Model
from openerp.addons import decimal_precision as dp


class product_supplierinfo(Model):
_inherit = 'product.supplierinfo'

Expand All @@ -37,19 +38,17 @@ def _get_integrated_price(
res[psi.id] = 0
return res


_columns = {
'integrated_price': fields.function(
_get_integrated_price, string='Unit Price',
digits_compute=dp.get_precision('Integrated Product Price'),
store={
'product.supplierinfo': (
lambda self, cr, uid, ids, context=None: ids,
[
'supplier_product_id',
'pricelist_ids',
], 10)}),
store={'product.supplierinfo': (
lambda self, cr, uid, ids, context=None: ids,
[
'supplier_product_id',
'pricelist_ids',
], 10)}),
'supplier_product_id': fields.many2one(
'product.product',
'Product in the Supplier Catalog', selected=True),
}
}
4 changes: 2 additions & 2 deletions integrated_trade_product/model/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
##############################################################################

from openerp import SUPERUSER_ID
from openerp.osv import fields
from openerp.osv.orm import Model


class res_partner(Model):
_inherit = 'res.partner'

# Public Function
def update_all_products_as_customer(self, cr, uid, ids, context=None):
""" Update all product.pricelistinfo of products template that are
""" Update all product.pricelistinfo of products template that are
linked to external products for defined customers"""
pitc_obj = self.pool['product.integrated.trade.catalog']
pitc_ids = pitc_obj.search(cr, SUPERUSER_ID, [
Expand Down
6 changes: 3 additions & 3 deletions integrated_trade_product/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def test_02_product_update(self):
# Change name in the supplier product
new_name = 'Supplier New Name'
self.pp_obj.write(cr, uid, [self.supplier_apple_id], {
'name': new_name,})
'name': new_name})

pp_c_apple = self.pp_obj.browse(cr, uid, self.customer_apple_id)
self.assertEqual(
pp_c_apple.seller_ids[0].product_name,
Expand All @@ -106,7 +106,7 @@ def test_02_product_update(self):
# new_code = '[SUPPLIER-NEW-CODE]'
# self.pp_obj.write(cr, uid, [self.supplier_apple_id], {
# 'default_code': new_code,})
#
#
# pp_c_apple = self.pp_obj.browse(cr, uid, self.customer_apple_id)
# self.assertEqual(
# pp_c_apple.seller_ids[0].product_code,
Expand Down
2 changes: 1 addition & 1 deletion integrated_trade_product/view/view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<record id="view_product_integrated_trade_catalog_tree" model="ir.ui.view">
<field name="model">product.integrated.trade.catalog</field>
<field name="arch" type="xml">
<tree string="Integrated Trade - Products Catalog">
<tree string="Integrated Trade - Products Catalog" editable="bottom">
<field name="product_tmpl_id" readonly="1"/>
<field name="customer_purchase_price" readonly="1"/>
<field name="supplier_product_default_code"/>
Expand Down

0 comments on commit 6193837

Please sign in to comment.