Skip to content

Commit

Permalink
[IMP]product_supplierinfo_for_customer_sale: Search SO by customerinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
toita86 committed Dec 16, 2024
1 parent b5a3abf commit b27d22f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
23 changes: 16 additions & 7 deletions product_supplierinfo_for_customer_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,30 @@ class SaleOrderLine(models.Model):

product_customer_code = fields.Char(
compute="_compute_product_customer_code",
store=True,
string="Product Customer Code",
)
product_customer_name = fields.Char(
compute="_compute_product_customer_code",
store=True,
string="Product Customer Name",
)

@api.depends("product_id")
@api.depends("order_id.partner_id", "product_id", "company_id")
def _compute_product_customer_code(self):
for line in self:
if line.product_id:
supplierinfo = line.product_id._select_customerinfo(
product_customer_name = product_customer_code = False

if line.product_id and line.order_id and line.order_id.partner_id:
customerinfo = line.product_id._select_customerinfo(
partner=line.order_partner_id,
quantity=None,
)
code = supplierinfo.product_code
else:
code = ""
line.product_customer_code = code
product_customer_code = customerinfo.product_code
product_customer_name = customerinfo.product_name

line.product_customer_code = product_customer_code
line.product_customer_name = product_customer_name

@api.onchange("product_id")
def product_id_change(self):
Expand Down
20 changes: 20 additions & 0 deletions product_supplierinfo_for_customer_sale/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@
</field>
</record>

<record id="sale_order_customerinfo_view_search" model="ir.ui.view">
<field name="name">sale.order.customerinfo.view.search</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']" position="after">
<field
name="order_line"
string="Product Customer Info"
filter_domain="[
'|',
('order_line.product_customer_code', 'ilike', self),
('order_line.product_customer_name', 'ilike', self),
]"
/>
</xpath>
</field>
</record>

<record id="product_customerinfo_tree_view" model="ir.ui.view">
<field name="name">product.customerinfo.tree.view</field>
<field name="model">product.customerinfo</field>
Expand Down

0 comments on commit b27d22f

Please sign in to comment.