Browse Source

[REF] cpo -> pog: rename everything

pull/145/head
robin.keunen 5 years ago
parent
commit
b2155fdfcc
  1. 4
      compute_purchase_order/models/__init__.py
  2. 1
      compute_purchase_order/readme/DESCRIPTION.rst
  3. 11
      compute_purchase_order/security/ir.model.access.csv
  4. 1
      compute_purchase_order/tests/__init__.py
  5. 16
      purchase_order_generator/README.rst
  6. 0
      purchase_order_generator/__init__.py
  7. 10
      purchase_order_generator/__manifest__.py
  8. 4
      purchase_order_generator/models/__init__.py
  9. 0
      purchase_order_generator/models/product_template.py
  10. 6
      purchase_order_generator/models/purchase_order.py
  11. 32
      purchase_order_generator/models/purchase_order_generator.py
  12. 12
      purchase_order_generator/models/purchase_order_generator_line.py
  13. 0
      purchase_order_generator/readme/CONTRIBUTORS.rst
  14. 1
      purchase_order_generator/readme/DESCRIPTION.rst
  15. 0
      purchase_order_generator/readme/USAGE.rst
  16. 11
      purchase_order_generator/security/ir.model.access.csv
  17. 16
      purchase_order_generator/static/description/index.html
  18. 1
      purchase_order_generator/tests/__init__.py
  19. 42
      purchase_order_generator/tests/test_pog.py
  20. 0
      purchase_order_generator/views/product_template.xml
  21. 0
      purchase_order_generator/views/purchase_order.xml
  22. 34
      purchase_order_generator/views/purchase_order_generator.xml

4
compute_purchase_order/models/__init__.py

@ -1,4 +0,0 @@
from . import purchase_order
from . import computed_purchase_order
from . import computed_purchase_order_line
from . import product_template

1
compute_purchase_order/readme/DESCRIPTION.rst

@ -1 +0,0 @@
Compute purchase order from selected products.

11
compute_purchase_order/security/ir.model.access.csv

@ -1,11 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_purchase_order,purchase.order,model_computed_purchase_order,purchase.group_purchase_user,1,1,1,1
access_purchase_order_manager,purchase.order,model_computed_purchase_order,purchase.group_purchase_manager,1,1,1,1
access_purchase_order_stock_worker,purchase.order,model_computed_purchase_order,stock.group_stock_user,1,0,0,0
access_purchase_order_invoicing_payments,purchase.order,model_computed_purchase_order,account.group_account_invoice,1,1,0,0
access_purchase_order_line,purchase.order.line user,model_computed_purchase_order_line,purchase.group_purchase_user,1,1,1,1
access_purchase_order_line_manager,purchase.order.line manager,model_computed_purchase_order_line,purchase.group_purchase_manager,1,1,1,1
access_purchase_order_line_stock_worker,purchase.order.line,model_computed_purchase_order_line,stock.group_stock_user,1,0,0,0
access_purchase_order_line_invoicing_payments,purchase.order.line,model_computed_purchase_order_line,account.group_account_invoice,1,1,0,0

1
compute_purchase_order/tests/__init__.py

@ -1 +0,0 @@
from . import test_cpo

16
compute_purchase_order/README.rst → purchase_order_generator/README.rst

@ -1,6 +1,6 @@
=======================
Computed Purchase Order
=======================
========================
Purchase Order Generator
========================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
@ -14,12 +14,12 @@ Computed Purchase Order
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-beescoop%2Fobeesdoo-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-beescoop%2Fobeesdoo-lightgray.png?logo=github
:target: https://github.com/beescoop/obeesdoo/tree/12.0/compute_purchase_order
:target: https://github.com/beescoop/obeesdoo/tree/12.0/purchase_order_generator
:alt: beescoop/obeesdoo :alt: beescoop/obeesdoo
|badge1| |badge2| |badge3| |badge1| |badge2| |badge3|
Compute purchase order from selected products.
Generate purchase order from a product selection.
**Table of contents** **Table of contents**
@ -32,7 +32,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/beescoop/obeesdoo/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/beescoop/obeesdoo/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/beescoop/obeesdoo/issues/new?body=module:%20compute_purchase_order%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/beescoop/obeesdoo/issues/new?body=module:%20purchase_order_generator%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -42,7 +42,7 @@ Credits
Authors Authors
~~~~~~~ ~~~~~~~
* Coop IT Easy
* Coop IT Easy SCRLfs
Contributors Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
@ -53,6 +53,6 @@ Contributors
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
This module is part of the `beescoop/obeesdoo <https://github.com/beescoop/obeesdoo/tree/12.0/compute_purchase_order>`_ project on GitHub.
This module is part of the `beescoop/obeesdoo <https://github.com/beescoop/obeesdoo/tree/12.0/purchase_order_generator>`_ project on GitHub.
You are welcome to contribute. You are welcome to contribute.

0
compute_purchase_order/__init__.py → purchase_order_generator/__init__.py

10
compute_purchase_order/__manifest__.py → purchase_order_generator/__manifest__.py

@ -3,17 +3,17 @@
# Vincent Van Rossem <vincent@coopiteasy.be> # Vincent Van Rossem <vincent@coopiteasy.be>
# 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": "Computed Purchase Order",
"name": "Purchase Order Generator",
"version": "12.0.1.0.0", "version": "12.0.1.0.0",
"category": "Purchase Order", "category": "Purchase Order",
"summary": "Compute purchase order from selected products",
"author": "Coop IT Easy",
"website": "https://github.com/coopiteasy/procurement-addons",
"summary": "Generate purchase order from a product selection",
"author": "Coop IT Easy SCRLfs",
"website": "https://github.com/beescoop/obeesdoo/",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["purchase", "beesdoo_stock_coverage"], "depends": ["purchase", "beesdoo_stock_coverage"],
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"views/computed_purchase_order.xml",
"views/purchase_order_generator.xml",
"views/purchase_order.xml", "views/purchase_order.xml",
], ],
} }

4
purchase_order_generator/models/__init__.py

@ -0,0 +1,4 @@
from . import purchase_order
from . import purchase_order_generator
from . import purchase_order_generator_line
from . import product_template

0
compute_purchase_order/models/product_template.py → purchase_order_generator/models/product_template.py

6
compute_purchase_order/models/purchase_order.py → purchase_order_generator/models/purchase_order.py

@ -9,9 +9,9 @@ class PurchaseOrder(models.Model):
_inherit = "purchase.order" _inherit = "purchase.order"
original_cpo_id = fields.Many2one( original_cpo_id = fields.Many2one(
"computed.purchase.order",
string="Original CPO",
help="CPO used to generate this Purchase Order",
"purchase.order.generator",
string="Original POG",
help="POG used to generate this Purchase Order",
) )

32
compute_purchase_order/models/computed_purchase_order.py → purchase_order_generator/models/purchase_order_generator.py

@ -7,12 +7,12 @@ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
class ComputedPurchaseOrder(models.Model):
_description = "Computed Purchase Order"
_name = "computed.purchase.order"
class PurchaseOrderGenerator(models.Model):
_description = "Purchase Order Generator"
_name = "purchase.order.generator"
_order = "id desc" _order = "id desc"
name = fields.Char(string="CPO Reference", default=_("New"))
name = fields.Char(string="POG Reference", default=_("New"))
order_date = fields.Datetime( order_date = fields.Datetime(
string="Purchase Order Date", string="Purchase Order Date",
default=fields.Datetime.now, default=fields.Datetime.now,
@ -21,7 +21,7 @@ class ComputedPurchaseOrder(models.Model):
) )
date_planned = fields.Datetime( date_planned = fields.Datetime(
string="Date Planned", string="Date Planned",
default=fields.Datetime.now, # default=lambda _: fields.Datetime.now()
default=fields.Datetime.now,
) )
supplier_id = fields.Many2one( supplier_id = fields.Many2one(
comodel_name="res.partner", comodel_name="res.partner",
@ -29,13 +29,13 @@ class ComputedPurchaseOrder(models.Model):
readonly=True, readonly=True,
help="Supplier of the purchase order.", help="Supplier of the purchase order.",
) )
cpo_line_ids = fields.One2many(
comodel_name="computed.purchase.order.line",
pog_line_ids = fields.One2many(
comodel_name="purchase.order.generator.line",
inverse_name="cpo_id", inverse_name="cpo_id",
string="Order Lines", string="Order Lines",
) )
total_amount = fields.Float( total_amount = fields.Float(
string="Total Amount (w/o VAT)", compute="_compute_cpo_total"
string="Total Amount (w/o VAT)", compute="compute_pog_total"
) )
generated_purchase_order_ids = fields.One2many( generated_purchase_order_ids = fields.One2many(
comodel_name="purchase.order", comodel_name="purchase.order",
@ -48,10 +48,10 @@ class ComputedPurchaseOrder(models.Model):
) )
@api.multi @api.multi
@api.depends("cpo_line_ids", "cpo_line_ids.purchase_quantity")
def _compute_cpo_total(self):
@api.depends("pog_line_ids", "pog_line_ids.purchase_quantity")
def compute_pog_total(self):
for cpo in self: for cpo in self:
total_amount = sum(cpol.subtotal for cpol in cpo.cpo_line_ids)
total_amount = sum(cpol.subtotal for cpol in cpo.pog_line_ids)
cpo.total_amount = total_amount cpo.total_amount = total_amount
@api.model @api.model
@ -71,11 +71,11 @@ class ComputedPurchaseOrder(models.Model):
@api.model @api.model
def generate_cpo(self): def generate_cpo(self):
order_line_obj = self.env["computed.purchase.order.line"]
order_line_obj = self.env["purchase.order.generator.line"]
product_ids = self.env.context.get("active_ids", []) product_ids = self.env.context.get("active_ids", [])
supplier = self._get_selected_supplier() supplier = self._get_selected_supplier()
name = "CPO {} {}".format(supplier.name, fields.Date.today())
name = "POG {} {}".format(supplier.name, fields.Date.today())
cpo = self.create({"name": name, "supplier_id": supplier.id}) cpo = self.create({"name": name, "supplier_id": supplier.id})
for product_id in product_ids: for product_id in product_ids:
@ -95,7 +95,7 @@ class ComputedPurchaseOrder(models.Model):
) )
action = { action = {
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
"res_model": "computed.purchase.order",
"res_model": "purchase.order.generator",
"res_id": cpo.id, "res_id": cpo.id,
"view_type": "form", "view_type": "form",
"view_mode": "form,tree", "view_mode": "form,tree",
@ -107,7 +107,7 @@ class ComputedPurchaseOrder(models.Model):
def create_purchase_order(self): def create_purchase_order(self):
self.ensure_one() self.ensure_one()
if sum(self.cpo_line_ids.mapped("purchase_quantity")) == 0:
if sum(self.pog_line_ids.mapped("purchase_quantity")) == 0:
raise ValidationError( raise ValidationError(
"You need at least a product to generate " "a Purchase Order" "You need at least a product to generate " "a Purchase Order"
) )
@ -120,7 +120,7 @@ class ComputedPurchaseOrder(models.Model):
} }
) )
for cpo_line in self.cpo_line_ids:
for cpo_line in self.pog_line_ids:
if cpo_line.purchase_quantity > 0: if cpo_line.purchase_quantity > 0:
pol = self.env["purchase.order.line"].create( pol = self.env["purchase.order.line"].create(
{ {

12
compute_purchase_order/models/computed_purchase_order_line.py → purchase_order_generator/models/purchase_order_generator_line.py

@ -10,14 +10,14 @@ from odoo.exceptions import ValidationError
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
class ComputedPurchaseOrderLine(models.Model):
_description = "Computed Purchase Order Line"
_name = "computed.purchase.order.line"
class PurchaseOrderGeneratorLine(models.Model):
_description = "Purchase Order Generator Line"
_name = "purchase.order.generator.line"
name = fields.Char(string="Product Name", compute="_compute_name") name = fields.Char(string="Product Name", compute="_compute_name")
cpo_id = fields.Many2one( cpo_id = fields.Many2one(
comodel_name="computed.purchase.order",
string="Computed Purchase Order",
comodel_name="purchase.order.generator",
string="Purchase Order Generator",
) )
product_template_id = fields.Many2one( product_template_id = fields.Many2one(
comodel_name="product.template", comodel_name="product.template",
@ -146,7 +146,7 @@ class ComputedPurchaseOrderLine(models.Model):
if len(si) == 0: if len(si) == 0:
raise ValidationError( raise ValidationError(
_("CPO supplier does not sell product {name}").format(
_("POG supplier does not sell product {name}").format(
name=cpol.product_template_id.name name=cpol.product_template_id.name
) )
) )

0
compute_purchase_order/readme/CONTRIBUTORS.rst → purchase_order_generator/readme/CONTRIBUTORS.rst

1
purchase_order_generator/readme/DESCRIPTION.rst

@ -0,0 +1 @@
Generate purchase order from a product selection.

0
compute_purchase_order/readme/USAGE.rst → purchase_order_generator/readme/USAGE.rst

11
purchase_order_generator/security/ir.model.access.csv

@ -0,0 +1,11 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_purchase_order,purchase.order,model_purchase_order_generator,purchase.group_purchase_user,1,1,1,1
access_purchase_order_manager,purchase.order,model_purchase_order_generator,purchase.group_purchase_manager,1,1,1,1
access_purchase_order_stock_worker,purchase.order,model_purchase_order_generator,stock.group_stock_user,1,0,0,0
access_purchase_order_invoicing_payments,purchase.order,model_purchase_order_generator,account.group_account_invoice,1,1,0,0
access_purchase_order_line,purchase.order.line user,model_purchase_order_generator_line,purchase.group_purchase_user,1,1,1,1
access_purchase_order_line_manager,purchase.order.line manager,model_purchase_order_generator_line,purchase.group_purchase_manager,1,1,1,1
access_purchase_order_line_stock_worker,purchase.order.line,model_purchase_order_generator_line,stock.group_stock_user,1,0,0,0
access_purchase_order_line_invoicing_payments,purchase.order.line,model_purchase_order_generator_line,account.group_account_invoice,1,1,0,0

16
compute_purchase_order/static/description/index.html → purchase_order_generator/static/description/index.html

@ -4,7 +4,7 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Computed Purchase Order</title>
<title>Purchase Order Generator</title>
<style type="text/css"> <style type="text/css">
/* /*
@ -360,15 +360,15 @@ ul.auto-toc {
</style> </style>
</head> </head>
<body> <body>
<div class="document" id="computed-purchase-order">
<h1 class="title">Computed Purchase Order</h1>
<div class="document" id="purchase-order-generator">
<h1 class="title">Purchase Order Generator</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/beescoop/obeesdoo/tree/12.0/compute_purchase_order"><img alt="beescoop/obeesdoo" src="https://img.shields.io/badge/github-beescoop%2Fobeesdoo-lightgray.png?logo=github" /></a></p>
<p>Compute purchase order from selected products.</p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/beescoop/obeesdoo/tree/12.0/purchase_order_generator"><img alt="beescoop/obeesdoo" src="https://img.shields.io/badge/github-beescoop%2Fobeesdoo-lightgray.png?logo=github" /></a></p>
<p>Generate purchase order from a product selection.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
<ul class="simple"> <ul class="simple">
@ -386,7 +386,7 @@ ul.auto-toc {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/beescoop/obeesdoo/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/beescoop/obeesdoo/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/beescoop/obeesdoo/issues/new?body=module:%20compute_purchase_order%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/beescoop/obeesdoo/issues/new?body=module:%20purchase_order_generator%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -394,7 +394,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<div class="section" id="authors"> <div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2> <h2><a class="toc-backref" href="#id3">Authors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Coop IT Easy</li>
<li>Coop IT Easy SCRLfs</li>
</ul> </ul>
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
@ -406,7 +406,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2> <h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<p>This module is part of the <a class="reference external" href="https://github.com/beescoop/obeesdoo/tree/12.0/compute_purchase_order">beescoop/obeesdoo</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/beescoop/obeesdoo/tree/12.0/purchase_order_generator">beescoop/obeesdoo</a> project on GitHub.</p>
<p>You are welcome to contribute.</p> <p>You are welcome to contribute.</p>
</div> </div>
</div> </div>

1
purchase_order_generator/tests/__init__.py

@ -0,0 +1 @@
from . import test_pog

42
compute_purchase_order/tests/test_cpo.py → purchase_order_generator/tests/test_pog.py

@ -30,40 +30,40 @@ class TestCPO(TransactionCase):
] ]
) )
cpo_obj = self.env["computed.purchase.order"]
cpo_action = cpo_obj.with_context(
pog_obj = self.env["purchase.order.generator"]
pog_action = pog_obj.with_context(
active_ids=[self.ptemplate1.id] active_ids=[self.ptemplate1.id]
).generate_cpo() ).generate_cpo()
cpo = cpo_obj.browse(cpo_action["res_id"])
cpol = cpo.cpo_line_ids # expect one line
pog = pog_obj.browse(pog_action["res_id"])
pogl = pog.pog_line_ids # expect one line
self.assertEquals(cpo.supplier_id, self.supplier)
self.assertEquals(cpol.product_template_id, self.ptemplate1)
self.assertEquals(cpol.product_price, supplierinfo.price)
self.assertEquals(cpol.purchase_quantity, supplierinfo.min_qty)
self.assertEquals(pog.supplier_id, self.supplier)
self.assertEquals(pogl.product_template_id, self.ptemplate1)
self.assertEquals(pogl.product_price, supplierinfo.price)
self.assertEquals(pogl.purchase_quantity, supplierinfo.min_qty)
# testing triggers # testing triggers
expected_subtotal = supplierinfo.price * supplierinfo.min_qty expected_subtotal = supplierinfo.price * supplierinfo.min_qty
self.assertEquals(cpol.subtotal, expected_subtotal)
self.assertEquals(pogl.subtotal, expected_subtotal)
cpol.purchase_quantity = 4
pogl.purchase_quantity = 4
expected_subtotal = supplierinfo.price * 4 expected_subtotal = supplierinfo.price * 4
self.assertEquals(cpol.subtotal, expected_subtotal)
self.assertEquals(pogl.subtotal, expected_subtotal)
cpo_form = Form(cpo)
with cpo_form.cpo_line_ids.edit(index=0) as line_form:
pog_form = Form(pog)
with pog_form.pog_line_ids.edit(index=0) as line_form:
line_form.product_template_id = self.ptemplate2 line_form.product_template_id = self.ptemplate2
self.assertEquals(line_form.product_template_id, self.ptemplate2) self.assertEquals(line_form.product_template_id, self.ptemplate2)
cpo = cpo_form.save()
cpol = cpo.cpo_line_ids
pog = pog_form.save()
pogl = pog.pog_line_ids
expected_subtotal = supplierinfo2.price * supplierinfo2.min_qty expected_subtotal = supplierinfo2.price * supplierinfo2.min_qty
self.assertEquals(cpol.product_price, supplierinfo2.price)
self.assertEquals(cpol.purchase_quantity, supplierinfo2.min_qty)
self.assertEquals(cpol.subtotal, expected_subtotal)
self.assertEquals(pogl.product_price, supplierinfo2.price)
self.assertEquals(pogl.purchase_quantity, supplierinfo2.min_qty)
self.assertEquals(pogl.subtotal, expected_subtotal)
def test_generate_po(self): def test_generate_po(self):
cpo_obj = self.env["computed.purchase.order"]
cpo_obj = self.env["purchase.order.generator"]
cpo_action = cpo_obj.with_context( cpo_action = cpo_obj.with_context(
active_ids=[self.ptemplate1.id, self.ptemplate2.id] active_ids=[self.ptemplate1.id, self.ptemplate2.id]
).generate_cpo() ).generate_cpo()
@ -72,9 +72,9 @@ class TestCPO(TransactionCase):
po = self.env["purchase.order"].browse(po_action["res_id"]) po = self.env["purchase.order"].browse(po_action["res_id"])
self.assertEquals(cpo.supplier_id, po.partner_id) self.assertEquals(cpo.supplier_id, po.partner_id)
self.assertEquals(len(cpo.cpo_line_ids), len(po.order_line))
self.assertEquals(len(cpo.pog_line_ids), len(po.order_line))
lines = zip( lines = zip(
cpo.cpo_line_ids.sorted(lambda l: l.product_template_id),
cpo.pog_line_ids.sorted(lambda l: l.product_template_id),
po.order_line.sorted(lambda l: l.product_id.product_tmpl_id), po.order_line.sorted(lambda l: l.product_id.product_tmpl_id),
) )
for cpol, pol in lines: for cpol, pol in lines:

0
compute_purchase_order/views/product_template.xml → purchase_order_generator/views/product_template.xml

0
compute_purchase_order/views/purchase_order.xml → purchase_order_generator/views/purchase_order.xml

34
compute_purchase_order/views/computed_purchase_order.xml → purchase_order_generator/views/purchase_order_generator.xml

@ -3,9 +3,9 @@
<!-- views--> <!-- views-->
<!--tree--> <!--tree-->
<record id="computed_purchase_order_tree" model="ir.ui.view">
<field name="name">computed.purchase.order.tree</field>
<field name="model">computed.purchase.order</field>
<record id="purchase_order_generator_tree" model="ir.ui.view">
<field name="name">purchase.order.generator.tree</field>
<field name="model">purchase.order.generator</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree> <tree>
<field name="name"/> <field name="name"/>
@ -18,9 +18,9 @@
</record> </record>
<!-- form --> <!-- form -->
<record id="computed_purchase_order_form" model="ir.ui.view">
<field name="name">computed.purchase.order.form</field>
<field name="model">computed.purchase.order</field>
<record id="purchase_order_generator_form" model="ir.ui.view">
<field name="name">purchase.order.generator.form</field>
<field name="model">purchase.order.generator</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<header> <header>
@ -55,10 +55,10 @@
</group> </group>
<field name="cpo_line_ids"> <!--context="{'cpo_seller_id': supplier_id}"> -->
<field name="pog_line_ids">
<tree name="order_lines" string="Order Lines" <tree name="order_lines" string="Order Lines"
editable='bottom'> editable='bottom'>
<field name="product_template_id"/> <!--domain="[('main_seller_id', '=', cpo_seller_id)]"/> -->
<field name="product_template_id"/>
<field name="qty_available" readonly='1'/> <field name="qty_available" readonly='1'/>
<field name="virtual_available" readonly='1'/> <field name="virtual_available" readonly='1'/>
<field name="uom_id" readonly='1'/> <field name="uom_id" readonly='1'/>
@ -79,8 +79,8 @@
</record> </record>
<!-- filters--> <!-- filters-->
<record id="computed_purchase_order_filter" model="ir.ui.view">
<field name="model">computed.purchase.order</field>
<record id="purchase_order_generator_filter" model="ir.ui.view">
<field name="model">purchase.order.generator</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search> <search>
<field name="supplier_id"/> <field name="supplier_id"/>
@ -90,20 +90,20 @@
<!-- Menu item --> <!-- Menu item -->
<record id="action_computed_purchase_order" model="ir.actions.act_window">
<field name="name">Computed Purchase Orders</field>
<field name="res_model">computed.purchase.order</field>
<record id="action_purchase_order_generator" model="ir.actions.act_window">
<field name="name">Purchase Order Generators</field>
<field name="res_model">purchase.order.generator</field>
</record> </record>
<menuitem id="computed_purchase_order"
<menuitem id="purchase_order_generator"
parent="purchase.menu_procurement_management" parent="purchase.menu_procurement_management"
action="action_computed_purchase_order"/>
action="action_purchase_order_generator"/>
<!-- Actions --> <!-- Actions -->
<record id="action_generate_cpo" model="ir.actions.server"> <record id="action_generate_cpo" model="ir.actions.server">
<field name="name">Compute Purchase Order</field>
<field name="model_id" ref="model_computed_purchase_order"/>
<field name="name">Generate Purchase Order</field>
<field name="model_id" ref="model_purchase_order_generator"/>
<field name="binding_model_id" ref="product.model_product_template"/> <field name="binding_model_id" ref="product.model_product_template"/>
<field name="state">code</field> <field name="state">code</field>
<field name="code"> <field name="code">
Loading…
Cancel
Save