Browse Source

[IMP] p_o_g: Filter product based on supplier

pull/181/head
Rémy Taymans 4 years ago
parent
commit
2577c08880
  1. 2
      purchase_order_generator/__manifest__.py
  2. 17
      purchase_order_generator/models/purchase_order_generator_line.py
  3. 3
      purchase_order_generator/views/purchase_order_generator.xml

2
purchase_order_generator/__manifest__.py

@ -4,7 +4,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Purchase Order Generator", "name": "Purchase Order Generator",
"version": "12.0.2.0.0",
"version": "12.0.2.1.0",
"category": "Purchase Order", "category": "Purchase Order",
"summary": "Generate purchase order from a product selection", "summary": "Generate purchase order from a product selection",
"author": "Coop IT Easy SCRLfs", "author": "Coop IT Easy SCRLfs",

17
purchase_order_generator/models/purchase_order_generator_line.py

@ -113,6 +113,23 @@ class PurchaseOrderGeneratorLine(models.Model):
for cpol in self: for cpol in self:
cpol.purchase_quantity = cpol.minimum_purchase_qty cpol.purchase_quantity = cpol.minimum_purchase_qty
@api.onchange("product_template_id")
def _onchange_product_template_id(self):
"""
Change domain on product_template_id based on supplier given
in the cpo.
"""
default_supplier = self._context.get("cpo_seller_id")
product_ids = []
if default_supplier:
product_ids = self.env["product.template"].search(
[
("main_seller_id", "=", default_supplier),
("purchase_ok", "=", True),
]
).ids
return {"domain": {"product_template_id": [("id", "in", product_ids)]}}
@api.multi @api.multi
@api.depends("purchase_quantity") @api.depends("purchase_quantity")
def _compute_coverage_and_subtotal(self): def _compute_coverage_and_subtotal(self):

3
purchase_order_generator/views/purchase_order_generator.xml

@ -55,7 +55,8 @@
</group> </group>
<field name="pog_line_ids">
<field name="pog_line_ids"
context="{'cpo_seller_id': supplier_id}">
<tree name="order_lines" string="Order Lines" <tree name="order_lines" string="Order Lines"
editable='bottom'> editable='bottom'>
<field name="product_template_id"/> <field name="product_template_id"/>

Loading…
Cancel
Save