[REF] *: rename name into partner_id on supplierinfo

Task: 2673000
Part-of: odoo/odoo#78732
This commit is contained in:
William Henrotin
2021-10-27 15:48:51 +00:00
parent 403c06504d
commit f3fe2d50d9
43 changed files with 156 additions and 156 deletions
@@ -466,7 +466,7 @@ class AccountEdiFormat(models.Model):
invoice_line_form.product_id = product
break
if partner:
product_supplier = self.env['product.supplierinfo'].search([('name', '=', partner.id), ('product_code', '=', code.text)])
product_supplier = self.env['product.supplierinfo'].search([('partner_id', '=', partner.id), ('product_code', '=', code.text)])
if product_supplier and product_supplier.product_id:
invoice_line_form.product_id = product_supplier.product_id
break
@@ -17,7 +17,7 @@
<record id="product_supplierinfo_subcontracting" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product.product_delivery_02_product_template"/>
<field name="name" ref="base.res_partner_12"/>
<field name="partner_id" ref="base.res_partner_12"/>
<field name="sequence">1</field>
<field name="delay">1</field>
<field name="min_qty">1</field>
+3 -3
View File
@@ -9,12 +9,12 @@ class SupplierInfo(models.Model):
is_subcontractor = fields.Boolean('Subcontracted', compute='_compute_is_subcontractor', help="Choose a vendor of type subcontractor if you want to subcontract the product")
@api.depends('name', 'product_id', 'product_tmpl_id')
@api.depends('partner_id', 'product_id', 'product_tmpl_id')
def _compute_is_subcontractor(self):
for supplier in self:
boms = supplier.product_id.variant_bom_ids
boms |= supplier.product_tmpl_id.bom_ids.filtered(lambda b: not b.product_id or b.product_id in (supplier.product_id or supplier.product_tmpl_id.product_variant_ids))
supplier.is_subcontractor = supplier.name in boms.subcontractor_ids
supplier.is_subcontractor = supplier.partner_id in boms.subcontractor_ids
class ProductProduct(models.Model):
@@ -22,5 +22,5 @@ class ProductProduct(models.Model):
def _prepare_sellers(self, params=False):
if params and params.get('subcontractor_ids'):
return super()._prepare_sellers(params=params).filtered(lambda s: s.name in params.get('subcontractor_ids'))
return super()._prepare_sellers(params=params).filtered(lambda s: s.partner_id in params.get('subcontractor_ids'))
return super()._prepare_sellers(params=params)
@@ -10,8 +10,8 @@ class ReportBomStructure(models.AbstractModel):
def _get_subcontracting_line(self, bom, seller, level, bom_quantity):
ratio_uom_seller = seller.product_uom.ratio / bom.product_uom_id.ratio
return {
'name': seller.name.display_name,
'partner_id': seller.name.id,
'name': seller.partner_id.display_name,
'partner_id': seller.partner_id.id,
'quantity': bom_quantity,
'uom': bom.product_uom_id.name,
'prod_cost': seller.price / ratio_uom_seller,
@@ -574,12 +574,12 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
self.comp2_bom.write({'type': 'subcontract', 'subcontractor_ids': [Command.link(self.subcontractor_partner1.id)]})
self.env['product.supplierinfo'].create({
'product_tmpl_id': self.finished.product_tmpl_id.id,
'name': self.subcontractor_partner1.id,
'partner_id': self.subcontractor_partner1.id,
'price': 10,
})
supplier = self.env['product.supplierinfo'].create({
'product_tmpl_id': self.comp2.product_tmpl_id.id,
'name': self.subcontractor_partner1.id,
'partner_id': self.subcontractor_partner1.id,
'price': 5,
})
self.assertTrue(supplier.is_subcontractor)
@@ -5,7 +5,7 @@
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product.product_supplierinfo_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="is_subcontractor" readonly="1"/>
</xpath>
</field>
@@ -151,11 +151,11 @@ class TestBomPriceSubcontracting(TestBomPrice):
})
suppliers = self.env['product.supplierinfo'].create([
{
'name': partner.id,
'partner_id': partner.id,
'product_tmpl_id': self.dining_table.product_tmpl_id.id,
'price': 150.0,
}, {
'name': partner.id,
'partner_id': partner.id,
'product_tmpl_id': self.table_head.product_tmpl_id.id,
'price': 120.0, # 10 by Unit because uom_po_id is in dozen
}
@@ -31,7 +31,7 @@ class TestSubcontractingDropshippingFlows(TestMrpSubcontractingCommon):
self.env['product.supplierinfo'].create({
'product_tmpl_id': self.finished.product_tmpl_id.id,
'name': self.subcontractor_partner1.id
'partner_id': self.subcontractor_partner1.id
})
partner = self.env['res.partner'].create({
@@ -39,7 +39,7 @@ class TestSubcontractingDropshippingFlows(TestMrpSubcontractingCommon):
})
self.env['product.supplierinfo'].create({
'product_tmpl_id': self.comp2.product_tmpl_id.id,
'name': partner.id
'partner_id': partner.id
})
# Create a receipt picking from the subcontractor
@@ -91,10 +91,10 @@ class TestSubcontractingDropshippingFlows(TestMrpSubcontractingCommon):
# Create a supplier and set it to component
vendor = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'})
self.env['product.supplierinfo'].create({
'name': vendor.id,
'partner_id': vendor.id,
'price': 50,
})
self.comp1.write({'seller_ids': [(0, 0, {'name': vendor.id, 'product_code': 'COMP1'})]})
self.comp1.write({'seller_ids': [(0, 0, {'partner_id': vendor.id, 'product_code': 'COMP1'})]})
# Purchase 1 BOM to the subcontractor
po = Form(self.env['purchase.order'])
po.partner_id = self.subcontractor_partner1
+26 -26
View File
@@ -559,7 +559,7 @@
<record id="product_supplierinfo_1" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_6_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">750</field>
@@ -568,7 +568,7 @@
<record id="product_supplierinfo_2" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_6_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">790</field>
@@ -577,7 +577,7 @@
<record id="product_supplierinfo_2bis" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_6_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">3</field>
<field name="min_qty">3</field>
<field name="price">785</field>
@@ -586,7 +586,7 @@
<record id="product_supplierinfo_3" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_7_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">13.0</field>
@@ -595,7 +595,7 @@
<record id="product_supplierinfo_4" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_7_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">14.4</field>
@@ -604,7 +604,7 @@
<record id="product_supplierinfo_5" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_8_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">2</field>
<field name="min_qty">5</field>
<field name="price">1299</field>
@@ -613,7 +613,7 @@
<record id="product_supplierinfo_6" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_8_product_template"/>
<field name="name" ref="base.res_partner_12"/>
<field name="partner_id" ref="base.res_partner_12"/>
<field name="delay">4</field>
<field name="min_qty">1</field>
<field name="price">1399</field>
@@ -622,7 +622,7 @@
<record id="product_supplierinfo_7" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_10_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">2</field>
<field name="min_qty">1</field>
<field name="price">120.50</field>
@@ -631,7 +631,7 @@
<record id="product_supplierinfo_8" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_11_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">2</field>
<field name="min_qty">1</field>
<field name="price">28</field>
@@ -640,7 +640,7 @@
<record id="product_supplierinfo_9" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_13_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">5</field>
<field name="min_qty">1</field>
<field name="price">78</field>
@@ -649,7 +649,7 @@
<record id="product_supplierinfo_10" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_16_product_template"/>
<field name="name" ref="base.res_partner_3"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field name="delay">1</field>
<field name="min_qty">1</field>
<field name="price">20</field>
@@ -658,7 +658,7 @@
<record id="product_supplierinfo_12" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_20_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">1700</field>
@@ -667,7 +667,7 @@
<record id="product_supplierinfo_13" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_20_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">4</field>
<field name="min_qty">5</field>
<field name="price">1720</field>
@@ -676,7 +676,7 @@
<record id="product_supplierinfo_14" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_22_product_template"/>
<field name="name" ref="base.res_partner_2"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">2010</field>
@@ -685,7 +685,7 @@
<record id="product_supplierinfo_15" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_24_product_template"/>
<field name="name" ref="base.res_partner_2"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field name="delay">3</field>
<field name="min_qty">1</field>
<field name="price">876</field>
@@ -694,7 +694,7 @@
<record id="product_supplierinfo_16" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_25_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">8</field>
<field name="min_qty">1</field>
<field name="price">287</field>
@@ -703,7 +703,7 @@
<record id="product_supplierinfo_17" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_delivery_02_product_template"/>
<field name="name" ref="base.res_partner_2"/>
<field name="partner_id" ref="base.res_partner_2"/>
<field name="delay">4</field>
<field name="min_qty">1</field>
<field name="price">390</field>
@@ -712,7 +712,7 @@
<record id="product_supplierinfo_18" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_delivery_01_product_template"/>
<field name="name" ref="base.res_partner_3"/>
<field name="partner_id" ref="base.res_partner_3"/>
<field name="delay">2</field>
<field name="min_qty">12</field>
<field name="price">90</field>
@@ -721,7 +721,7 @@
<record id="product_supplierinfo_19" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_delivery_01_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">4</field>
<field name="min_qty">1</field>
<field name="price">66</field>
@@ -730,7 +730,7 @@
<record id="product_supplierinfo_20" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_delivery_02_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">5</field>
<field name="min_qty">1</field>
<field name="price">35</field>
@@ -739,7 +739,7 @@
<record id="product_supplierinfo_21" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_delivery_01_product_template"/>
<field name="name" ref="base.res_partner_12"/>
<field name="partner_id" ref="base.res_partner_12"/>
<field name="delay">7</field>
<field name="min_qty">1</field>
<field name="price">55</field>
@@ -748,7 +748,7 @@
<record id="product_supplierinfo_22" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_9_product_template"/>
<field name="name" ref="base.res_partner_12"/>
<field name="partner_id" ref="base.res_partner_12"/>
<field name="delay">4</field>
<field name="min_qty">0</field>
<field name="price">10</field>
@@ -757,7 +757,7 @@
<record id="product_supplierinfo_23" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_27_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">10</field>
<field name="min_qty">0</field>
<field name="price">95.50</field>
@@ -766,7 +766,7 @@
<record id="product_supplierinfo_24" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_12_product_template"/>
<field name="name" ref="base.res_partner_1"/>
<field name="partner_id" ref="base.res_partner_1"/>
<field name="delay">3</field>
<field name="min_qty">0</field>
<field name="price">120.50</field>
@@ -775,7 +775,7 @@
<record id="product_supplierinfo_25" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_12_product_template"/>
<field name="name" ref="base.res_partner_4"/>
<field name="partner_id" ref="base.res_partner_4"/>
<field name="delay">2</field>
<field name="min_qty">0</field>
<field name="price">130.50</field>
@@ -784,7 +784,7 @@
<record id="product_supplierinfo_26" model="product.supplierinfo">
<field name="product_tmpl_id" ref="product_product_5_product_template"/>
<field name="name" ref="base.res_partner_10"/>
<field name="partner_id" ref="base.res_partner_10"/>
<field name="delay">1</field>
<field name="min_qty">0</field>
<field name="price">145</field>
+9 -8
View File
@@ -306,7 +306,7 @@ class ProductProduct(models.Model):
def _compute_product_code(self):
for product in self:
for supplier_info in product.seller_ids:
if supplier_info.name.id == product._context.get('partner_id'):
if supplier_info.partner_id.id == product._context.get('partner_id'):
product.code = supplier_info.product_code or product.default_code
break
else:
@@ -316,7 +316,7 @@ class ProductProduct(models.Model):
def _compute_partner_ref(self):
for product in self:
for supplier_info in product.seller_ids:
if supplier_info.name.id == product._context.get('partner_id'):
if supplier_info.partner_id.id == product._context.get('partner_id'):
product_name = supplier_info.product_name or product.default_code or product.name
product.partner_ref = '%s%s' % (product.code and '[%s] ' % product.code or '', product_name)
break
@@ -501,7 +501,7 @@ class ProductProduct(models.Model):
if partner_ids:
supplier_info = self.env['product.supplierinfo'].sudo().search([
('product_tmpl_id', 'in', product_template_ids),
('name', 'in', partner_ids),
('partner_id', 'in', partner_ids),
])
# Prefetch the fields used by the `name_get`, so `browse` doesn't fetch other fields
# Use `load=False` to not call `name_get` for the `product_tmpl_id` and `product_id`
@@ -583,7 +583,7 @@ class ProductProduct(models.Model):
# still no results, partner in context: search on supplier info as last hope to find something
if not product_ids and self._context.get('partner_id'):
suppliers_ids = self.env['product.supplierinfo']._search([
('name', '=', self._context.get('partner_id')),
('partner_id', '=', self._context.get('partner_id')),
'|',
('product_code', operator, name),
('product_name', operator, name)], access_rights_uid=name_get_uid)
@@ -636,7 +636,7 @@ class ProductProduct(models.Model):
'target': 'new'}
def _prepare_sellers(self, params=False):
return self.seller_ids.filtered(lambda s: s.name.active).sorted(lambda s: (s.sequence, -s.min_qty, s.price, s.id))
return self.seller_ids.filtered(lambda s: s.partner_id.active).sorted(lambda s: (s.sequence, -s.min_qty, s.price, s.id))
def _select_seller(self, partner_id=False, quantity=0.0, date=None, uom_id=False, params=False):
self.ensure_one()
@@ -657,13 +657,13 @@ class ProductProduct(models.Model):
continue
if seller.date_end and seller.date_end < date:
continue
if partner_id and seller.name not in [partner_id, partner_id.parent_id]:
if partner_id and seller.partner_id not in [partner_id, partner_id.parent_id]:
continue
if quantity is not None and float_compare(quantity_uom_seller, seller.min_qty, precision_digits=precision) == -1:
continue
if seller.product_id and seller.product_id != self:
continue
if not res or res.name == seller.name:
if not res or res.partner_id == seller.partner_id:
res |= seller
return res.sorted('price')[:1]
@@ -813,8 +813,9 @@ class SupplierInfo(models.Model):
_name = "product.supplierinfo"
_description = "Supplier Pricelist"
_order = 'sequence, min_qty DESC, price, id'
_rec_name = 'partner_id'
name = fields.Many2one(
partner_id = fields.Many2one(
'res.partner', 'Vendor',
ondelete='cascade', required=True,
help="Vendor of this product", check_company=True)
+2 -2
View File
@@ -93,7 +93,7 @@ class SupplierInfo(models.Model):
product_templates_ids = random.sample(product_templates_ids, int(len(product_templates_ids) * 0.95))
def get_company_id(values, counter, random):
partner = self.env['res.partner'].browse(values['name'])
partner = self.env['res.partner'].browse(values['partner_id'])
if partner.company_id:
return partner.company_id.id
return random.choice(company_ids)
@@ -105,7 +105,7 @@ class SupplierInfo(models.Model):
return random.randint(1, 10)
return [
('name', populate.randomize(partner_ids)),
('partner_id', populate.randomize(partner_ids)),
('company_id', populate.compute(get_company_id)),
('product_tmpl_id', populate.iterate(product_templates_ids)),
('product_name', populate.constant("SI-{counter}")),
@@ -42,25 +42,25 @@ class TestProductPricelist(TransactionCase):
self.env['product.supplierinfo'].create([
{
'name': self.res_partner_1.id,
'partner_id': self.res_partner_1.id,
'product_tmpl_id': self.ipad_mini.product_tmpl_id.id,
'delay': 3,
'min_qty': 1,
'price': 750,
}, {
'name': self.res_partner_4.id,
'partner_id': self.res_partner_4.id,
'product_tmpl_id': self.ipad_mini.product_tmpl_id.id,
'delay': 3,
'min_qty': 1,
'price': 790,
}, {
'name': self.res_partner_4.id,
'partner_id': self.res_partner_4.id,
'product_tmpl_id': self.ipad_mini.product_tmpl_id.id,
'delay': 3,
'min_qty': 3,
'price': 785,
}, {
'name': self.res_partner_4.id,
'partner_id': self.res_partner_4.id,
'product_tmpl_id': self.monitor.product_tmpl_id.id,
'delay': 3,
'min_qty': 3,
+5 -5
View File
@@ -22,8 +22,8 @@ class TestSeller(TransactionCase):
def test_10_sellers(self):
self.product_service.write({'seller_ids': [
(0, 0, {'name': self.asustec.id, 'product_code': 'ASUCODE'}),
(0, 0, {'name': self.camptocamp.id, 'product_code': 'C2CCODE'}),
(0, 0, {'partner_id': self.asustec.id, 'product_code': 'ASUCODE'}),
(0, 0, {'partner_id': self.camptocamp.id, 'product_code': 'C2CCODE'}),
]})
default_code = self.product_service.code
@@ -40,9 +40,9 @@ class TestSeller(TransactionCase):
'name': 'Saucisson Inc.',
})
self.product_consu.write({'seller_ids': [
(0, 0, {'name': self.asustec.id, 'product_code': 'A', 'company_id': company_a.id}),
(0, 0, {'name': self.asustec.id, 'product_code': 'B', 'company_id': company_b.id}),
(0, 0, {'name': self.asustec.id, 'product_code': 'NO', 'company_id': False}),
(0, 0, {'partner_id': self.asustec.id, 'product_code': 'A', 'company_id': company_a.id}),
(0, 0, {'partner_id': self.asustec.id, 'product_code': 'B', 'company_id': company_b.id}),
(0, 0, {'partner_id': self.asustec.id, 'product_code': 'NO', 'company_id': False}),
]})
names = self.product_consu.with_context(
+6 -6
View File
@@ -603,7 +603,7 @@
<group>
<group name="vendor" string="Vendor">
<field name="product_variant_count" invisible="1"/>
<field name="name" context="{'res_partner_search_mode': 'supplier'}"/>
<field name="partner_id" context="{'res_partner_search_mode': 'supplier'}"/>
<field name="product_name"/>
<field name="product_code"/>
<label for="delay"/>
@@ -638,13 +638,13 @@
<field name="model">product.supplierinfo</field>
<field name="arch" type="xml">
<search string="Vendor">
<field name="name"/>
<field name="partner_id"/>
<field name="product_tmpl_id"/>
<filter string="Active" name="active" domain="['|', ('date_end', '=', False), ('date_end', '&gt;=', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d'))]"/>
<filter string="Archived" name="archived" domain="[('date_end', '&lt;', (context_today() - datetime.timedelta(days=1)).strftime('%Y-%m-%d'))]"/>
<group expand="0" string="Group By">
<filter string="Product" name="groupby_product" domain="[]" context="{'group_by': 'product_tmpl_id'}"/>
<filter string="Vendor" name="groupby_vendor" domain="[]" context="{'group_by': 'name'}"/>
<filter string="Vendor" name="groupby_vendor" domain="[]" context="{'group_by': 'partner_id'}"/>
</group>
</search>
</field>
@@ -658,14 +658,14 @@
<field name="min_qty"/>
<field name="delay"/>
<field name="price"/>
<field name="name"/>
<field name="partner_id"/>
<field name="currency_id"/>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<div class="row mb4">
<strong class="col-6">
<span t-esc="record.name.value"/>
<span t-esc="record.partner_id.value"/>
</strong>
<strong class="col-6 text-right">
<strong><field name="price" widget="monetary"/></strong>
@@ -690,7 +690,7 @@
<field name="arch" type="xml">
<tree string="Vendor Information" multi_edit="1">
<field name="sequence" widget="handle"/>
<field name="name" readonly="1"/>
<field name="partner_id" readonly="1"/>
<field name="product_id" readonly="1" optional="hide"
invisible="context.get('product_template_invisible_variant', False)"
groups="product.group_product_variant"/>
+3 -3
View File
@@ -91,9 +91,9 @@ class ProductCategory(models.Model):
class ProductSupplierinfo(models.Model):
_inherit = "product.supplierinfo"
@api.onchange('name')
def _onchange_name(self):
self.currency_id = self.name.property_purchase_currency_id.id or self.env.company.currency_id.id
@api.onchange('partner_id')
def _onchange_partner_id(self):
self.currency_id = self.partner_id.property_purchase_currency_id.id or self.env.company.currency_id.id
class ProductPackaging(models.Model):
+4 -4
View File
@@ -442,7 +442,7 @@ class PurchaseOrder(models.Model):
def _prepare_supplier_info(self, partner, line, price, currency):
# Prepare supplierinfo data when adding a product
return {
'name': partner.id,
'partner_id': partner.id,
'sequence': max(line.product_id.seller_ids.mapped('sequence')) + 1 if line.product_id.seller_ids else 1,
'min_qty': 0.0,
'price': price,
@@ -457,7 +457,7 @@ class PurchaseOrder(models.Model):
for line in self.order_line:
# Do not add a contact as a supplier
partner = self.partner_id if not self.partner_id.parent_id else self.partner_id.parent_id
if line.product_id and partner not in line.product_id.seller_ids.mapped('name') and len(line.product_id.seller_ids) <= 10:
if line.product_id and partner not in line.product_id.seller_ids.partner_id and len(line.product_id.seller_ids) <= 10:
# Convert the price in the right currency.
currency = partner.property_purchase_currency_id or self.env.company.currency_id
price = self.currency_id._convert(line.price_unit, currency, line.company_id, line.date_order or fields.Date.today(), round=False)
@@ -1225,7 +1225,7 @@ class PurchaseOrderLine(models.Model):
if not self.product_id:
return
seller_min_qty = self.product_id.seller_ids\
.filtered(lambda r: r.name == self.order_id.partner_id and (not r.product_id or r.product_id == self.product_id))\
.filtered(lambda r: r.partner_id == self.order_id.partner_id and (not r.product_id or r.product_id == self.product_id))\
.sorted(key=lambda r: r.min_qty)
if seller_min_qty:
self.product_qty = seller_min_qty[0].min_qty or 1.0
@@ -1289,7 +1289,7 @@ class PurchaseOrderLine(models.Model):
@api.model
def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, company_id, supplier, po):
partner = supplier.name
partner = supplier.partner_id
uom_po_qty = product_uom._compute_quantity(product_qty, product_id.uom_po_id)
# _select_seller is used if the supplier have different price depending
# the quantities ordered.
+1 -1
View File
@@ -19,7 +19,7 @@
<xpath expr="//field[@name='min_qty']" position="attributes">
<attribute name="optional">hide</attribute>
</xpath>
<xpath expr="//field[@name='name']" position="attributes">
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
<xpath expr="//field[@name='product_id']" position="attributes">
@@ -425,7 +425,7 @@ class TestPurchaseMrpFlow(TransactionCase):
vendor1 = self.env['res.partner'].create({'name': 'aaa', 'email': 'from.test@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 50,
})
@@ -189,7 +189,7 @@ class PurchaseRequisitionLine(models.Model):
if res.requisition_id.state not in ['draft', 'cancel', 'done'] and res.requisition_id.is_quantity_copy == 'none':
supplier_infos = self.env['product.supplierinfo'].search([
('product_id', '=', vals.get('product_id')),
('name', '=', res.requisition_id.vendor_id.id),
('partner_id', '=', res.requisition_id.vendor_id.id),
])
if not any(s.purchase_requisition_id for s in supplier_infos):
res.create_supplier_info()
@@ -218,7 +218,7 @@ class PurchaseRequisitionLine(models.Model):
if purchase_requisition.type_id.quantity_copy == 'none' and purchase_requisition.vendor_id:
# create a supplier_info only in case of blanket order
self.env['product.supplierinfo'].create({
'name': purchase_requisition.vendor_id.id,
'partner_id': purchase_requisition.vendor_id.id,
'product_id': self.product_id.id,
'product_tmpl_id': self.product_id.product_tmpl_id.id,
'price': self.price_unit,
@@ -46,19 +46,19 @@ class TestPurchaseRequisition(TestPurchaseRequisitionCommon):
# and check the quantity
seller_partner1 = self.res_partner_1
supplierinfo09 = self.env['product.supplierinfo'].search([
('name', '=', seller_partner1.id),
('partner_id', '=', seller_partner1.id),
('product_id', '=', self.product_09.id),
('purchase_requisition_id', '=', requisition_blanket.id),
])
self.assertEqual(supplierinfo09.name, seller_partner1, 'The supplierinfo is not the good one')
self.assertEqual(supplierinfo09.partner_id, seller_partner1, 'The supplierinfo is not the good one')
self.assertEqual(supplierinfo09.price, price_product09, 'The supplierinfo is not the good one')
supplierinfo13 = self.env['product.supplierinfo'].search([
('name', '=', seller_partner1.id),
('partner_id', '=', seller_partner1.id),
('product_id', '=', self.product_13.id),
('purchase_requisition_id', '=', requisition_blanket.id),
])
self.assertEqual(supplierinfo13.name, seller_partner1, 'The supplierinfo is not the good one')
self.assertEqual(supplierinfo13.partner_id, seller_partner1, 'The supplierinfo is not the good one')
self.assertEqual(supplierinfo13.price, price_product13, 'The supplierinfo is not the good one')
# Put the requisition in done Status
@@ -82,7 +82,7 @@ class TestPurchaseRequisition(TestPurchaseRequisitionCommon):
})
supplier_info = self.env['product.supplierinfo'].create({
'product_id': product.id,
'name': vendor.id,
'partner_id': vendor.id,
})
# create a empty blanquet order
@@ -110,6 +110,6 @@ class TestPurchaseRequisition(TestPurchaseRequisitionCommon):
})
new_si = self.env['product.supplierinfo'].search([
('product_id', '=', product.id),
('name', '=', vendor.id)
('partner_id', '=', vendor.id)
]) - supplier_info
self.assertEqual(new_si.purchase_requisition_id, requisition_blanket, 'the blanket order is not linked to the supplier info')
@@ -55,7 +55,7 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon):
vendor1 = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'})
vendor2 = self.env['res.partner'].create({'name': 'BBB', 'email': 'from.test2@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 50,
})
product_test = self.env['product.product'].create({
@@ -119,7 +119,7 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon):
# Update the sequence of the blanket order's supplier info.
supplier_info1.sequence = 2
requisition_blanket.line_ids.supplier_info_ids.sequence = 1
# In [13]: [(x.sequence, x.min_qty, x.price, x.name.name) for x in supplier_info1 + requisition_blanket.line_ids.supplier_info_ids]
# In [13]: [(x.sequence, x.min_qty, x.price, x.partner_id.name) for x in supplier_info1 + requisition_blanket.line_ids.supplier_info_ids]
# Out[13]: [(2, 0.0, 50.0, 'AAA'), (1, 0.0, 50.0, 'BBB')]
# Second stock move
@@ -152,7 +152,7 @@ class TestPurchaseRequisitionStock(TestPurchaseRequisitionCommon):
route_mto = warehouse1.mto_pull_id.route_id.id
vendor1 = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 50,
})
product_1 = self.env['product.product'].create({
+2 -2
View File
@@ -84,12 +84,12 @@ class SupplierInfo(models.Model):
('state', 'in', ('purchase', 'done')),
('order_line.product_id', 'in',
self.product_tmpl_id.product_variant_ids.ids),
('partner_id', 'in', self.name.ids),
('partner_id', 'in', self.partner_id.ids),
], order='date_order')
for supplier in self:
products = supplier.product_tmpl_id.product_variant_ids
for purchase in purchases:
if purchase.partner_id != supplier.name:
if purchase.partner_id != supplier.partner_id:
continue
if not (products & purchase.order_line.product_id):
continue
+1 -1
View File
@@ -183,7 +183,7 @@ class Orderpoint(models.Model):
supplier_id = fields.Many2one(
'product.supplierinfo', string='Product Supplier', check_company=True,
domain="['|', ('product_id', '=', product_id), '&', ('product_id', '=', False), ('product_tmpl_id', '=', product_tmpl_id)]")
vendor_id = fields.Many2one(related='supplier_id.name', string="Vendor", store=True)
vendor_id = fields.Many2one(related='supplier_id.partner_id', string="Vendor", store=True)
@api.depends('product_id.purchase_order_line_ids', 'product_id.purchase_order_line_ids.state')
def _compute_qty(self):
+4 -4
View File
@@ -71,7 +71,7 @@ class StockRule(models.Model):
msg = _('There is no matching vendor price to generate the purchase order for product %s (no vendor defined, minimum quantity not reached, dates not valid, ...). Go on the product form and complete the list of vendors.') % (procurement.product_id.display_name)
errors.append((procurement, msg))
partner = supplier.name
partner = supplier.partner_id
# we put `supplier_info` in values for extensibility purposes
procurement.values['supplier'] = supplier
procurement.values['propagate_cancel'] = rule.propagate_cancel
@@ -140,7 +140,7 @@ class StockRule(models.Model):
# If it does not exist a PO line for current procurement.
# Generate the create values for it and add it to a list in
# order to create it in batch.
partner = procurement.values['supplier'].name
partner = procurement.values['supplier'].partner_id
po_line_values.append(self.env['purchase.order.line']._prepare_purchase_order_line_from_procurement(
procurement.product_id, procurement.product_qty,
procurement.product_uom, procurement.company_id,
@@ -229,7 +229,7 @@ class StockRule(models.Model):
return merged_procurements
def _update_purchase_order_line(self, product_id, product_qty, product_uom, company_id, values, line):
partner = values['supplier'].name
partner = values['supplier'].partner_id
procurement_uom_po_qty = product_uom._compute_quantity(product_qty, product_id.uom_po_id)
seller = product_id.with_company(company_id)._select_seller(
partner_id=partner,
@@ -269,7 +269,7 @@ class StockRule(models.Model):
# the common procurements values. The common values are taken from an
# arbitrary procurement. In this case the first.
values = values[0]
partner = values['supplier'].name
partner = values['supplier'].partner_id
purchase_date = schedule_date - relativedelta(days=supplier_delay)
fpos = self.env['account.fiscal.position'].with_company(company_id).get_fiscal_position(partner.id)
+3 -3
View File
@@ -34,20 +34,20 @@ class PurchaseTestCommon(TestStockCommon):
cls.product_1.write({
'type': 'product',
'route_ids': [(6, 0, [cls.route_buy, cls.route_mto])],
'seller_ids': [(0, 0, {'name': cls.partner_1.id, 'delay': 5})]})
'seller_ids': [(0, 0, {'partner_id': cls.partner_1.id, 'delay': 5})]})
cls.t_shirt = cls.env['product.product'].create({
'name': 'T-shirt',
'description': 'Internal Notes',
'route_ids': [(6, 0, [cls.route_buy, cls.route_mto])],
'seller_ids': [(0, 0, {'name': cls.partner_1.id, 'delay': 5})]
'seller_ids': [(0, 0, {'partner_id': cls.partner_1.id, 'delay': 5})]
})
# Update product_2 with type, route and Delivery Lead Time
cls.product_2.write({
'type': 'product',
'route_ids': [(6, 0, [cls.route_buy, cls.route_mto])],
'seller_ids': [(0, 0, {'name': cls.partner_1.id, 'delay': 2})]})
'seller_ids': [(0, 0, {'partner_id': cls.partner_1.id, 'delay': 2})]})
cls.res_users_purchase_user = cls.env['res.users'].create({
'company_id': cls.env.ref('base.main_company').id,
@@ -113,7 +113,7 @@ class TestCreatePicking(common.TestProductCommon):
})
seller = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 12.0,
})
@@ -247,7 +247,7 @@ class TestCreatePicking(common.TestProductCommon):
})
seller = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 12.0,
})
@@ -389,7 +389,7 @@ class TestCreatePicking(common.TestProductCommon):
picking_type_out = self.env.ref('stock.picking_type_out')
partner = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 50,
})
@@ -540,7 +540,7 @@ class TestCreatePicking(common.TestProductCommon):
'name': 'Jhon'
})
seller = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 12.0,
})
vendor = self.env['res.partner'].create({
@@ -14,7 +14,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
cls.warehouse = cls.env.ref('stock.warehouse0')
cust_location = cls.env.ref('stock.stock_location_customers')
seller = cls.env['product.supplierinfo'].create({
'name': cls.customer.id,
'partner_id': cls.customer.id,
'price': 100.0,
})
product = cls.env['product.product'].create({
@@ -260,7 +260,7 @@ class TestMoveCancelPropagation(PurchaseTestCommon):
'name': 'Steve'
})
seller = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 10.0,
})
product_car = self.env['product.product'].create({
@@ -39,7 +39,7 @@ class TestOnchangeProductId(TransactionCase):
amount='0.00',
type_tax_use='purchase'))
supplierinfo_vals = {
'name': partner_id.id,
'partner_id': partner_id.id,
'price': 121.0,
}
@@ -8,7 +8,7 @@ class TestProductTemplate(TransactionCase):
})
seller = self.env['product.supplierinfo'].create({
'name': partner.id,
'partner_id': partner.id,
'price': 12.0,
'delay': 1,
'product_code': 'VOB2a',
@@ -170,7 +170,7 @@ class TestPurchaseLeadTime(PurchaseTestCommon):
product_1 = self.env['product.product'].create({
'name': 'AAA',
'route_ids': [(4, self.route_buy)],
'seller_ids': [(0, 0, {'name': self.partner_1.id, 'delay': 5})]
'seller_ids': [(0, 0, {'partner_id': self.partner_1.id, 'delay': 5})]
})
# create a move for product_1 from stock to output and reserve to trigger the
@@ -219,7 +219,7 @@ class TestPurchaseLeadTime(PurchaseTestCommon):
'product_name': 'Vendor Name',
'product_code': 'Vendor Code',
})
partner = self.t_shirt.seller_ids[:1].name
partner = self.t_shirt.seller_ids[:1].partner_id
t_shirt = self.t_shirt.with_context(
lang=partner.lang,
partner_id=partner.id,
@@ -293,8 +293,8 @@ class TestPurchaseLeadTime(PurchaseTestCommon):
'name': 'Chicory',
'type': 'product',
'seller_ids': [
(0, 0, {'name': vendor2.id, 'delay': 15.0, 'company_id': company2.id}),
(0, 0, {'name': vendor.id, 'delay': 1.0, 'company_id': company.id})
(0, 0, {'partner_id': vendor2.id, 'delay': 15.0, 'company_id': company2.id}),
(0, 0, {'partner_id': vendor.id, 'delay': 1.0, 'company_id': company.id})
]
})
orderpoint_form = Form(self.env['stock.warehouse.orderpoint'])
@@ -351,7 +351,7 @@ class TestPurchaseLeadTime(PurchaseTestCommon):
self.env['product.supplierinfo'].search([('product_tmpl_id', '=', self.product_1.product_tmpl_id.id)]).unlink()
self.env['product.supplierinfo'].create({
'name': self.partner_1.id,
'partner_id': self.partner_1.id,
'min_qty': 1,
'price': 1,
'delay': 7,
@@ -41,13 +41,13 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
def test_00_purchase_order_flow(self):
# Ensure product_id_2 doesn't have res_partner_1 as supplier
if self.partner_a in self.product_id_2.seller_ids.mapped('name'):
id_to_remove = self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_a).ids[0] if self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_a) else False
if self.partner_a in self.product_id_2.seller_ids.partner_id:
id_to_remove = self.product_id_2.seller_ids.filtered(lambda r: r.partner_id == self.partner_a).ids[0] if self.product_id_2.seller_ids.filtered(lambda r: r.partner_id == self.partner_a) else False
if id_to_remove:
self.product_id_2.write({
'seller_ids': [(2, id_to_remove, False)],
})
self.assertFalse(self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_a), 'Purchase: the partner should not be in the list of the product suppliers')
self.assertFalse(self.product_id_2.seller_ids.filtered(lambda r: r.partner_id == self.partner_a), 'Purchase: the partner should not be in the list of the product suppliers')
self.po = self.env['purchase.order'].create(self.po_vals)
self.assertTrue(self.po, 'Purchase: no purchase order created')
@@ -59,7 +59,7 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
self.assertEqual(self.po.state, 'purchase', 'Purchase: PO state should be "Purchase"')
self.assertEqual(self.po.invoice_status, 'to invoice', 'Purchase: PO invoice_status should be "Waiting Invoices"')
self.assertTrue(self.product_id_2.seller_ids.filtered(lambda r: r.name == self.partner_a), 'Purchase: the partner should be in the list of the product suppliers')
self.assertTrue(self.product_id_2.seller_ids.filtered(lambda r: r.partner_id == self.partner_a), 'Purchase: the partner should be in the list of the product suppliers')
seller = self.product_id_2._select_seller(partner_id=self.partner_a, quantity=2.0, date=self.po.date_planned, uom_id=self.product_id_2.uom_po_id)
price_unit = seller.price if seller else 0.0
@@ -27,7 +27,7 @@ class TestReorderingRule(TransactionCase):
product_form.detailed_type = 'product'
product_form.description = 'Internal Notes'
with product_form.seller_ids.new() as seller:
seller.name = cls.partner
seller.partner_id = cls.partner
product_form.route_ids.add(cls.env.ref('purchase_stock.route_warehouse0_buy'))
cls.product_01 = product_form.save()
@@ -205,7 +205,7 @@ class TestReorderingRule(TransactionCase):
})
vendor1 = self.env['res.partner'].create({'name': 'AAA', 'email': 'from.test@example.com'})
supplier_info1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 50,
})
product = self.env['product.product'].create({
@@ -265,7 +265,7 @@ class TestReorderingRule(TransactionCase):
product_form.name = 'Simple Product'
product_form.detailed_type = 'product'
with product_form.seller_ids.new() as s:
s.name = partner
s.partner_id = partner
product = product_form.save()
product_form = Form(self.env['product.product'])
@@ -274,7 +274,7 @@ class TestReorderingRule(TransactionCase):
product_form.route_ids.add(route_buy)
product_form.route_ids.add(route_mto)
with product_form.seller_ids.new() as s:
s.name = partner
s.partner_id = partner
product_buy_mto = product_form.save()
# Create Delivery Order of 20 product and 10 buy + MTO
@@ -363,7 +363,7 @@ class TestReorderingRule(TransactionCase):
product_form.name = 'Simple Product'
product_form.detailed_type = 'product'
with product_form.seller_ids.new() as s:
s.name = partner
s.partner_id = partner
product = product_form.save()
product_form = Form(self.env['product.product'])
@@ -372,7 +372,7 @@ class TestReorderingRule(TransactionCase):
product_form.route_ids.add(route_buy)
product_form.route_ids.add(route_mto)
with product_form.seller_ids.new() as s:
s.name = partner
s.partner_id = partner
product_buy_mto = product_form.save()
# Create Delivery Order of 20 product and 10 buy + MTO
@@ -470,12 +470,12 @@ class TestReorderingRule(TransactionCase):
"name": "Supplier B",
})
self.env["product.supplierinfo"].create({
"name": default_vendor.id,
"partner_id": default_vendor.id,
"product_tmpl_id": product.product_tmpl_id.id,
"delay": 7,
})
self.env["product.supplierinfo"].create({
"name": secondary_vendor.id,
"partner_id": secondary_vendor.id,
"product_tmpl_id": product.product_tmpl_id.id,
"delay": 10,
})
@@ -578,7 +578,7 @@ class TestReorderingRule(TransactionCase):
"name": "Supplier A",
})
self.env["product.supplierinfo"].create({
"name": default_vendor.id,
"partner_id": default_vendor.id,
"product_tmpl_id": product.product_tmpl_id.id,
"delay": 7,
})
@@ -12,7 +12,7 @@ class TestReplenishWizard(TestStockCommon):
# Create a supplier info witch the previous vendor
cls.supplierinfo = cls.env['product.supplierinfo'].create({
'name': cls.vendor.id,
'partner_id': cls.vendor.id,
'price': cls.product1_price,
})
@@ -73,14 +73,14 @@ class TestReplenishWizard(TestStockCommon):
supplierinfo1 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor1.id,
'partner_id': vendor1.id,
'min_qty': 1,
'price': 140,
'sequence': 1,
})
supplierinfo2 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor1.id,
'partner_id': vendor1.id,
'min_qty': 10,
'price': 100,
'sequence': 2,
@@ -121,21 +121,21 @@ class TestReplenishWizard(TestStockCommon):
supplierinfo1 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor1.id,
'partner_id': vendor1.id,
'min_qty': 1,
'price': 140,
'sequence': 1,
})
supplierinfo2 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor2.id,
'partner_id': vendor2.id,
'min_qty': 10,
'price': 90,
'sequence': 2,
})
supplierinfo3 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor1.id,
'partner_id': vendor1.id,
'min_qty': 10,
'price': 100,
'sequence': 3,
@@ -175,13 +175,13 @@ class TestReplenishWizard(TestStockCommon):
supplierinfo1 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 50,
'sequence': 2,
})
supplierinfo2 = self.env['product.supplierinfo'].create({
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'name': vendor2.id,
'partner_id': vendor2.id,
'price': 50,
'sequence': 1,
})
@@ -217,19 +217,19 @@ class TestReplenishWizard(TestStockCommon):
})
vendor1 = self.env['res.partner'].create({'name': 'vendor1', 'email': 'from.test@example.com'})
supplierinfo1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 100,
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'min_qty': 2
})
supplierinfo2 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 60,
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'min_qty': 10
})
supplierinfo3 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 80,
'product_tmpl_id': product_to_buy.product_tmpl_id.id,
'min_qty': 5
-1
View File
@@ -21,7 +21,6 @@ class TestOnchangeProductId(TransactionCase):
self.product_tmpl_model = self.env['product.template']
self.product_model = self.env['product.product']
self.product_uom_model = self.env['uom.uom']
self.supplierinfo_model = self.env["product.supplierinfo"]
self.pricelist_model = self.env['product.pricelist']
def test_onchange_product_id(self):
+2 -2
View File
@@ -192,7 +192,7 @@ class SaleOrderLine(models.Model):
:rtype: dict
"""
self.ensure_one()
partner_supplier = supplierinfo.name
partner_supplier = supplierinfo.partner_id
fpos = self.env['account.fiscal.position'].sudo().get_fiscal_position(partner_supplier.id)
date_order = self._purchase_get_date_order(supplierinfo)
return {
@@ -268,7 +268,7 @@ class SaleOrderLine(models.Model):
if not suppliers:
raise UserError(_("There is no vendor associated to the product %s. Please define a vendor for this product.") % (line.product_id.display_name,))
supplierinfo = suppliers[0]
partner_supplier = supplierinfo.name # yes, this field is not explicit .... it is a res.partner !
partner_supplier = supplierinfo.partner_id
# determine (or create) PO
purchase_order = supplier_po_map.get(partner_supplier.id)
+2 -2
View File
@@ -56,13 +56,13 @@ class TestCommonSalePurchaseNoChart(TestSaleCommon):
})
cls.supplierinfo1 = cls.env['product.supplierinfo'].create({
'name': cls.partner_vendor_service.id,
'partner_id': cls.partner_vendor_service.id,
'price': 100,
'product_tmpl_id': cls.service_purchase_1.product_tmpl_id.id,
'delay': 1,
})
cls.supplierinfo2 = cls.env['product.supplierinfo'].create({
'name': cls.partner_vendor_service.id,
'partner_id': cls.partner_vendor_service.id,
'price': 10,
'product_tmpl_id': cls.service_purchase_2.product_tmpl_id.id,
'delay': 5,
@@ -88,7 +88,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
self.sale_order_1.action_confirm()
self.sale_order_2.action_confirm()
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines_so1 = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_line1 = purchase_lines_so1[0]
@@ -136,7 +136,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
""" Confirm SO, cancel it, then re-confirm it should not regenerate a purchase line """
self.sale_order_1.action_confirm()
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_line = purchase_lines[0]
@@ -152,7 +152,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
self.assertEqual(len(purchase_order.activity_ids), 1, "One activity should be scheduled on the PO since a SO has been cancelled")
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_line = purchase_lines[0]
@@ -167,7 +167,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
self.sale_order_1.action_draft()
self.sale_order_1.action_confirm()
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_line = purchase_lines[0]
@@ -191,7 +191,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
"""
self.sale_order_1.action_confirm()
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_line = purchase_lines[0]
@@ -231,7 +231,7 @@ class TestSalePurchase(TestCommonSalePurchaseNoChart):
self.assertEqual(purchase_line.product_qty, sale_line_old_quantity, "The quantity on the PO line should not have changed.")
self.assertEqual(len(purchase_order.activity_ids), 2, "Always 2 activity on confirmed the PO")
purchase_order2 = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.name.id), ('state', '=', 'draft')])
purchase_order2 = self.env['purchase.order'].search([('partner_id', '=', self.supplierinfo1.partner_id.id), ('state', '=', 'draft')])
purchase_lines = self.env['purchase.order.line'].search([('sale_line_id', 'in', self.sale_order_1.order_line.ids)])
purchase_lines2 = purchase_lines.filtered(lambda pol: pol.order_id == purchase_order2)
purchase_line2 = purchase_lines2[0]
+1 -1
View File
@@ -26,7 +26,7 @@ class TestPackingNeg(TransactionCase):
'standard_price': 70.0,
'seller_ids': [(0, 0, {
'delay': 1,
'name': res_partner_2.id,
'partner_id': res_partner_2.id,
'min_qty': 2.0,})],
'uom_id': self.ref('uom.product_uom_unit'),
'uom_po_id': self.ref('uom.product_uom_unit'),
@@ -30,7 +30,7 @@ class TestCrossdock(common.TransactionCase):
p_f.categ_id = self.env.ref('product.product_category_1')
p_f.list_price = 100.0
with p_f.seller_ids.new() as seller:
seller.name = supplier_crossdock
seller.partner_id = supplier_crossdock
p_f.route_ids.add(wh_pps.crossdock_route_id)
cross_shop_product = p_f.save()
@@ -16,7 +16,7 @@ class TestDropship(common.TransactionCase):
# add a vendor
vendor1 = self.env['res.partner'].create({'name': 'vendor1'})
seller1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 8,
})
prod.write({'seller_ids': [(6, 0, [seller1.id])]})
@@ -84,7 +84,7 @@ class TestDropship(common.TransactionCase):
'uom_po_id': self.env.ref('uom.product_uom_unit').id,
'seller_ids': [(0, 0, {
'delay': 1,
'name': supplier_dropship.id,
'partner_id': supplier_dropship.id,
'min_qty': 2.0
})]
})
@@ -43,7 +43,7 @@ class TestProcurementException(common.TransactionCase):
with Form(product_with_no_seller) as f:
with f.seller_ids.new() as seller:
seller.delay = 1
seller.name = res_partner_2
seller.partner_id = res_partner_2
seller.min_qty = 2.0
# I confirm the sales order, no error this time
@@ -30,7 +30,7 @@ class TestStockValuation(ValuationReconciliationTestCommon):
# add a vendor
vendor1 = self.env['res.partner'].create({'name': 'vendor1'})
seller1 = self.env['product.supplierinfo'].create({
'name': vendor1.id,
'partner_id': vendor1.id,
'price': 8,
})
self.product1.write({'seller_ids': [(6, 0, [seller1.id])]})
@@ -144,7 +144,7 @@ tour.stepUtils.autoExpandMoreButtons('.o_form_readonly'),
position: 'right',
}, {
mobile: false,
trigger: ".o_field_widget[name=name] input",
trigger: ".o_field_widget[name=partner_id] input",
extra_trigger: ".modal-dialog",
content: _t('Select a seller'),
position: 'top',
@@ -160,7 +160,7 @@ tour.stepUtils.autoExpandMoreButtons('.o_form_readonly'),
position: 'bottom',
}, {
mobile: true,
trigger: ".o_form_editable .o_field_many2one[name=name] input",
trigger: ".o_form_editable .o_field_many2one[name=partner_id] input",
extra_trigger: ".modal:not(.o_inactive_modal) .o_form_editable div:contains('Vendor')",
content: _t("Select a vendor, or create a new one on the fly."),
position: "bottom",
@@ -208,7 +208,7 @@ tour.stepUtils.autoExpandMoreButtons('.o_form_readonly'),
}, {
mobile: false,
trigger: 'label:contains("Vendor Taxes")',
extra_trigger: ".o_field_widget[name=name] .o_external_button", // Wait name_create
extra_trigger: ".o_field_widget[name=partner_id] .o_external_button", // Wait name_create
// click somewhere else to exit cell focus
}, {
mobile: false,
@@ -273,7 +273,7 @@ tour.stepUtils.autoExpandMoreButtons('.o_form_readonly'),
position: 'bottom',
}, {
mobile: true,
trigger: '.o_form_editable .o_field_many2one[name="name"] input',
trigger: '.o_form_editable .o_field_many2one[name="partner_id"] input',
extra_trigger: ".modal:not(.o_inactive_modal) .o_form_editable div:contains('Vendor')",
content: _t("Select a vendor, or create a new one on the fly."),
position: "bottom",
@@ -286,7 +286,7 @@ tour.stepUtils.autoExpandMoreButtons('.o_form_readonly'),
position: 'right',
}, {
mobile: false,
trigger: ".o_field_widget[name=name] input",
trigger: ".o_field_widget[name=partner_id] input",
extra_trigger: ".modal-dialog",
content: _t('Select a seller'),
position: 'top',