Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions product_supplierinfo_for_customer/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"license": 'AGPL-3',
"depends": [
"base",
"sale",
"product",
],
"data": [
Expand Down
1 change: 1 addition & 0 deletions product_supplierinfo_for_customer/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import product_template
from . import res_partner
from . import product_pricelist
from . import sale_order_line
27 changes: 27 additions & 0 deletions product_supplierinfo_for_customer/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
from openerp import models, api


class SaleOrderLine2(models.Model):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the class name is always the model name in camel case


_inherit = 'sale.order.line'

@api.multi
def product_id_change(
self, pricelist, product, qty=0,
uom=False, qty_uos=0, uos=False, name='', partner_id=False,
lang=False, update_tax=True, date_order=False, packaging=False,
fiscal_position=False, flag=False):
res = super(SaleOrderLine2, self).product_id_change(
pricelist, product, qty=qty, uom=uom,
qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
lang=lang, update_tax=update_tax, date_order=date_order,
packaging=packaging, fiscal_position=fiscal_position,
flag=flag)
product_rec = self.env['product.product'].browse(product)
if res.get('value', {}).get('name') and product_rec.customer_ids.ids:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product_rec.customer_ids is sufficient

pc = product_rec.customer_ids.product_code
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there are multiple customer rules on the product?

pn = product_rec.customer_ids.product_name
if pn:
res['value']['name'] = pc + '--' + pn
return res