From b2155fdfccac884c0da37fc91fb17b20cf15aa06 Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Wed, 29 Apr 2020 19:27:28 +0200 Subject: [PATCH] [REF] cpo -> pog: rename everything --- compute_purchase_order/models/__init__.py | 4 -- compute_purchase_order/readme/DESCRIPTION.rst | 1 - .../security/ir.model.access.csv | 11 ----- compute_purchase_order/tests/__init__.py | 1 - .../README.rst | 16 +++---- .../__init__.py | 0 .../__manifest__.py | 10 ++--- purchase_order_generator/models/__init__.py | 4 ++ .../models/product_template.py | 0 .../models/purchase_order.py | 6 +-- .../models/purchase_order_generator.py | 32 +++++++------- .../models/purchase_order_generator_line.py | 12 +++--- .../readme/CONTRIBUTORS.rst | 0 .../readme/DESCRIPTION.rst | 1 + .../readme/USAGE.rst | 0 .../security/ir.model.access.csv | 11 +++++ .../static/description/index.html | 16 +++---- purchase_order_generator/tests/__init__.py | 1 + .../tests/test_pog.py | 42 +++++++++---------- .../views/product_template.xml | 0 .../views/purchase_order.xml | 0 .../views/purchase_order_generator.xml | 34 +++++++-------- 22 files changed, 101 insertions(+), 101 deletions(-) delete mode 100644 compute_purchase_order/models/__init__.py delete mode 100644 compute_purchase_order/readme/DESCRIPTION.rst delete mode 100644 compute_purchase_order/security/ir.model.access.csv delete mode 100644 compute_purchase_order/tests/__init__.py rename {compute_purchase_order => purchase_order_generator}/README.rst (75%) rename {compute_purchase_order => purchase_order_generator}/__init__.py (100%) rename {compute_purchase_order => purchase_order_generator}/__manifest__.py (64%) create mode 100644 purchase_order_generator/models/__init__.py rename {compute_purchase_order => purchase_order_generator}/models/product_template.py (100%) rename {compute_purchase_order => purchase_order_generator}/models/purchase_order.py (91%) rename compute_purchase_order/models/computed_purchase_order.py => purchase_order_generator/models/purchase_order_generator.py (84%) rename compute_purchase_order/models/computed_purchase_order_line.py => purchase_order_generator/models/purchase_order_generator_line.py (95%) rename {compute_purchase_order => purchase_order_generator}/readme/CONTRIBUTORS.rst (100%) create mode 100644 purchase_order_generator/readme/DESCRIPTION.rst rename {compute_purchase_order => purchase_order_generator}/readme/USAGE.rst (100%) create mode 100644 purchase_order_generator/security/ir.model.access.csv rename {compute_purchase_order => purchase_order_generator}/static/description/index.html (93%) create mode 100644 purchase_order_generator/tests/__init__.py rename compute_purchase_order/tests/test_cpo.py => purchase_order_generator/tests/test_pog.py (67%) rename {compute_purchase_order => purchase_order_generator}/views/product_template.xml (100%) rename {compute_purchase_order => purchase_order_generator}/views/purchase_order.xml (100%) rename compute_purchase_order/views/computed_purchase_order.xml => purchase_order_generator/views/purchase_order_generator.xml (74%) diff --git a/compute_purchase_order/models/__init__.py b/compute_purchase_order/models/__init__.py deleted file mode 100644 index 6fdf87d..0000000 --- a/compute_purchase_order/models/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from . import purchase_order -from . import computed_purchase_order -from . import computed_purchase_order_line -from . import product_template diff --git a/compute_purchase_order/readme/DESCRIPTION.rst b/compute_purchase_order/readme/DESCRIPTION.rst deleted file mode 100644 index e9f66f3..0000000 --- a/compute_purchase_order/readme/DESCRIPTION.rst +++ /dev/null @@ -1 +0,0 @@ -Compute purchase order from selected products. diff --git a/compute_purchase_order/security/ir.model.access.csv b/compute_purchase_order/security/ir.model.access.csv deleted file mode 100644 index 982809e..0000000 --- a/compute_purchase_order/security/ir.model.access.csv +++ /dev/null @@ -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 diff --git a/compute_purchase_order/tests/__init__.py b/compute_purchase_order/tests/__init__.py deleted file mode 100644 index 0246a73..0000000 --- a/compute_purchase_order/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import test_cpo diff --git a/compute_purchase_order/README.rst b/purchase_order_generator/README.rst similarity index 75% rename from compute_purchase_order/README.rst rename to purchase_order_generator/README.rst index f8e0c96..5d438e1 100644 --- a/compute_purchase_order/README.rst +++ b/purchase_order_generator/README.rst @@ -1,6 +1,6 @@ -======================= -Computed Purchase Order -======================= +======================== +Purchase Order Generator +======================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! 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 :alt: License: AGPL-3 .. |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 |badge1| |badge2| |badge3| -Compute purchase order from selected products. +Generate purchase order from a product selection. **Table of contents** @@ -32,7 +32,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. 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 -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -42,7 +42,7 @@ Credits Authors ~~~~~~~ -* Coop IT Easy +* Coop IT Easy SCRLfs Contributors ~~~~~~~~~~~~ @@ -53,6 +53,6 @@ Contributors Maintainers ~~~~~~~~~~~ -This module is part of the `beescoop/obeesdoo `_ project on GitHub. +This module is part of the `beescoop/obeesdoo `_ project on GitHub. You are welcome to contribute. diff --git a/compute_purchase_order/__init__.py b/purchase_order_generator/__init__.py similarity index 100% rename from compute_purchase_order/__init__.py rename to purchase_order_generator/__init__.py diff --git a/compute_purchase_order/__manifest__.py b/purchase_order_generator/__manifest__.py similarity index 64% rename from compute_purchase_order/__manifest__.py rename to purchase_order_generator/__manifest__.py index 8a9de1e..5587487 100644 --- a/compute_purchase_order/__manifest__.py +++ b/purchase_order_generator/__manifest__.py @@ -3,17 +3,17 @@ # Vincent Van Rossem # 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", "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", "depends": ["purchase", "beesdoo_stock_coverage"], "data": [ "security/ir.model.access.csv", - "views/computed_purchase_order.xml", + "views/purchase_order_generator.xml", "views/purchase_order.xml", ], } diff --git a/purchase_order_generator/models/__init__.py b/purchase_order_generator/models/__init__.py new file mode 100644 index 0000000..78eefbf --- /dev/null +++ b/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 diff --git a/compute_purchase_order/models/product_template.py b/purchase_order_generator/models/product_template.py similarity index 100% rename from compute_purchase_order/models/product_template.py rename to purchase_order_generator/models/product_template.py diff --git a/compute_purchase_order/models/purchase_order.py b/purchase_order_generator/models/purchase_order.py similarity index 91% rename from compute_purchase_order/models/purchase_order.py rename to purchase_order_generator/models/purchase_order.py index c72b2be..b17a488 100644 --- a/compute_purchase_order/models/purchase_order.py +++ b/purchase_order_generator/models/purchase_order.py @@ -9,9 +9,9 @@ class PurchaseOrder(models.Model): _inherit = "purchase.order" 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", ) diff --git a/compute_purchase_order/models/computed_purchase_order.py b/purchase_order_generator/models/purchase_order_generator.py similarity index 84% rename from compute_purchase_order/models/computed_purchase_order.py rename to purchase_order_generator/models/purchase_order_generator.py index 48766db..7c092c8 100644 --- a/compute_purchase_order/models/computed_purchase_order.py +++ b/purchase_order_generator/models/purchase_order_generator.py @@ -7,12 +7,12 @@ from odoo import models, fields, api, _ 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" - name = fields.Char(string="CPO Reference", default=_("New")) + name = fields.Char(string="POG Reference", default=_("New")) order_date = fields.Datetime( string="Purchase Order Date", default=fields.Datetime.now, @@ -21,7 +21,7 @@ class ComputedPurchaseOrder(models.Model): ) date_planned = fields.Datetime( string="Date Planned", - default=fields.Datetime.now, # default=lambda _: fields.Datetime.now() + default=fields.Datetime.now, ) supplier_id = fields.Many2one( comodel_name="res.partner", @@ -29,13 +29,13 @@ class ComputedPurchaseOrder(models.Model): readonly=True, 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", string="Order Lines", ) 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( comodel_name="purchase.order", @@ -48,10 +48,10 @@ class ComputedPurchaseOrder(models.Model): ) @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: - 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 @api.model @@ -71,11 +71,11 @@ class ComputedPurchaseOrder(models.Model): @api.model 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", []) 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}) for product_id in product_ids: @@ -95,7 +95,7 @@ class ComputedPurchaseOrder(models.Model): ) action = { "type": "ir.actions.act_window", - "res_model": "computed.purchase.order", + "res_model": "purchase.order.generator", "res_id": cpo.id, "view_type": "form", "view_mode": "form,tree", @@ -107,7 +107,7 @@ class ComputedPurchaseOrder(models.Model): def create_purchase_order(self): 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( "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: pol = self.env["purchase.order.line"].create( { diff --git a/compute_purchase_order/models/computed_purchase_order_line.py b/purchase_order_generator/models/purchase_order_generator_line.py similarity index 95% rename from compute_purchase_order/models/computed_purchase_order_line.py rename to purchase_order_generator/models/purchase_order_generator_line.py index ab97a90..710b7ba 100644 --- a/compute_purchase_order/models/computed_purchase_order_line.py +++ b/purchase_order_generator/models/purchase_order_generator_line.py @@ -10,14 +10,14 @@ from odoo.exceptions import ValidationError _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") 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( comodel_name="product.template", @@ -146,7 +146,7 @@ class ComputedPurchaseOrderLine(models.Model): if len(si) == 0: raise ValidationError( - _("CPO supplier does not sell product {name}").format( + _("POG supplier does not sell product {name}").format( name=cpol.product_template_id.name ) ) diff --git a/compute_purchase_order/readme/CONTRIBUTORS.rst b/purchase_order_generator/readme/CONTRIBUTORS.rst similarity index 100% rename from compute_purchase_order/readme/CONTRIBUTORS.rst rename to purchase_order_generator/readme/CONTRIBUTORS.rst diff --git a/purchase_order_generator/readme/DESCRIPTION.rst b/purchase_order_generator/readme/DESCRIPTION.rst new file mode 100644 index 0000000..ea924d5 --- /dev/null +++ b/purchase_order_generator/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Generate purchase order from a product selection. diff --git a/compute_purchase_order/readme/USAGE.rst b/purchase_order_generator/readme/USAGE.rst similarity index 100% rename from compute_purchase_order/readme/USAGE.rst rename to purchase_order_generator/readme/USAGE.rst diff --git a/purchase_order_generator/security/ir.model.access.csv b/purchase_order_generator/security/ir.model.access.csv new file mode 100644 index 0000000..dbb4063 --- /dev/null +++ b/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 diff --git a/compute_purchase_order/static/description/index.html b/purchase_order_generator/static/description/index.html similarity index 93% rename from compute_purchase_order/static/description/index.html rename to purchase_order_generator/static/description/index.html index 699639d..bf49414 100644 --- a/compute_purchase_order/static/description/index.html +++ b/purchase_order_generator/static/description/index.html @@ -4,7 +4,7 @@ -Computed Purchase Order +Purchase Order Generator -
-

Computed Purchase Order

+
+

Purchase Order Generator

-

Beta License: AGPL-3 beescoop/obeesdoo

-

Compute purchase order from selected products.

+

Beta License: AGPL-3 beescoop/obeesdoo

+

Generate purchase order from a product selection.

Table of contents

    @@ -386,7 +386,7 @@ ul.auto-toc {

    Bugs are tracked on GitHub Issues. 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 -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

@@ -394,7 +394,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Authors

    -
  • Coop IT Easy
  • +
  • Coop IT Easy SCRLfs
@@ -406,7 +406,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

Maintainers

-

This module is part of the beescoop/obeesdoo project on GitHub.

+

This module is part of the beescoop/obeesdoo project on GitHub.

You are welcome to contribute.

diff --git a/purchase_order_generator/tests/__init__.py b/purchase_order_generator/tests/__init__.py new file mode 100644 index 0000000..ef21616 --- /dev/null +++ b/purchase_order_generator/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pog diff --git a/compute_purchase_order/tests/test_cpo.py b/purchase_order_generator/tests/test_pog.py similarity index 67% rename from compute_purchase_order/tests/test_cpo.py rename to purchase_order_generator/tests/test_pog.py index c50830b..4a5f9d4 100644 --- a/compute_purchase_order/tests/test_cpo.py +++ b/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] ).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 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 - 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 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 - 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): - cpo_obj = self.env["computed.purchase.order"] + cpo_obj = self.env["purchase.order.generator"] cpo_action = cpo_obj.with_context( active_ids=[self.ptemplate1.id, self.ptemplate2.id] ).generate_cpo() @@ -72,9 +72,9 @@ class TestCPO(TransactionCase): po = self.env["purchase.order"].browse(po_action["res_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( - 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), ) for cpol, pol in lines: diff --git a/compute_purchase_order/views/product_template.xml b/purchase_order_generator/views/product_template.xml similarity index 100% rename from compute_purchase_order/views/product_template.xml rename to purchase_order_generator/views/product_template.xml diff --git a/compute_purchase_order/views/purchase_order.xml b/purchase_order_generator/views/purchase_order.xml similarity index 100% rename from compute_purchase_order/views/purchase_order.xml rename to purchase_order_generator/views/purchase_order.xml diff --git a/compute_purchase_order/views/computed_purchase_order.xml b/purchase_order_generator/views/purchase_order_generator.xml similarity index 74% rename from compute_purchase_order/views/computed_purchase_order.xml rename to purchase_order_generator/views/purchase_order_generator.xml index f6d56a1..ad5c78d 100644 --- a/compute_purchase_order/views/computed_purchase_order.xml +++ b/purchase_order_generator/views/purchase_order_generator.xml @@ -3,9 +3,9 @@ - - computed.purchase.order.tree - computed.purchase.order + + purchase.order.generator.tree + purchase.order.generator @@ -18,9 +18,9 @@ - - computed.purchase.order.form - computed.purchase.order + + purchase.order.generator.form + purchase.order.generator
@@ -55,10 +55,10 @@ - + - + @@ -79,8 +79,8 @@ - - computed.purchase.order + + purchase.order.generator @@ -90,20 +90,20 @@ - - Computed Purchase Orders - computed.purchase.order + + Purchase Order Generators + purchase.order.generator - + action="action_purchase_order_generator"/> - Compute Purchase Order - + Generate Purchase Order + code