From 31e321eee060c3ca173f4bdc9f08adb6263f07ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mart=C3=ADn=20Xifr=C3=A9?= Date: Thu, 19 Mar 2020 11:45:35 +0100 Subject: [PATCH 01/13] [12.0][ADD]supplier_calendar --- supplier_calendar/README.rst | 120 +++++ supplier_calendar/__init__.py | 3 + supplier_calendar/__manifest__.py | 23 + supplier_calendar/models/__init__.py | 6 + supplier_calendar/models/product.py | 12 + supplier_calendar/models/purchase.py | 23 + supplier_calendar/models/res_partner.py | 50 ++ supplier_calendar/models/stock_rule.py | 25 + supplier_calendar/readme/CONFIGURE.rst | 9 + supplier_calendar/readme/CONTRIBUTORS.rst | 4 + supplier_calendar/readme/DESCRIPTION.rst | 6 + supplier_calendar/readme/USAGE.rst | 9 + supplier_calendar/static/description/icon.png | Bin 0 -> 9455 bytes .../static/description/index.html | 451 ++++++++++++++++++ supplier_calendar/tests/__init__.py | 2 + .../tests/test_supplier_calendar.py | 107 +++++ supplier_calendar/views/product_view.xml | 15 + supplier_calendar/views/res_partner_view.xml | 20 + 18 files changed, 885 insertions(+) create mode 100644 supplier_calendar/README.rst create mode 100644 supplier_calendar/__init__.py create mode 100644 supplier_calendar/__manifest__.py create mode 100644 supplier_calendar/models/__init__.py create mode 100644 supplier_calendar/models/product.py create mode 100644 supplier_calendar/models/purchase.py create mode 100644 supplier_calendar/models/res_partner.py create mode 100644 supplier_calendar/models/stock_rule.py create mode 100644 supplier_calendar/readme/CONFIGURE.rst create mode 100644 supplier_calendar/readme/CONTRIBUTORS.rst create mode 100644 supplier_calendar/readme/DESCRIPTION.rst create mode 100644 supplier_calendar/readme/USAGE.rst create mode 100644 supplier_calendar/static/description/icon.png create mode 100644 supplier_calendar/static/description/index.html create mode 100644 supplier_calendar/tests/__init__.py create mode 100644 supplier_calendar/tests/test_supplier_calendar.py create mode 100644 supplier_calendar/views/product_view.xml create mode 100644 supplier_calendar/views/res_partner_view.xml diff --git a/supplier_calendar/README.rst b/supplier_calendar/README.rst new file mode 100644 index 00000000000..245be061dd5 --- /dev/null +++ b/supplier_calendar/README.rst @@ -0,0 +1,120 @@ +================= +Supplier Calendar +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/12.0/supplier_calendar + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-supplier_calendar + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a Calendar to the ResPartner model. This calendar can then +used as the basis of the proper computation of start/end dates based on the +delivery lead time of the supplier in this and other modules. + +In this module, the calendar is considered in the computation of the schedules +date of a stock picking and in the order date of a purchase order. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +* Go to *Settings* and activate the developer mode. + +* Go to *Settings > Technical > Resource > Working Time* and define your + resource calendar. + +* Go to *Contacts > Sales&Purchases > Purchase > Delay Calendar Type* + and assign Supplier Calendar and in *Factory Closing Days* assign the + Resource Calendar desired. + + +Usage +===== + +When a picking is created from a purchase order of a supplier, the lead +time used to calculate the scheduled date is computed in natural days. At the +same time, when a purchase order is created due to a a procurement +evaluation, its order date is also computed considering the lead time in +natural days. THis module adds the possibility of expressing the lead time +of a vendor in his own calendar. This way, the order dates of purchase +orders and the scheduled dates of receipts will only take into account the +supplier working days. + + +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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* ForgeFlow + +Contributors +~~~~~~~~~~~~ + +* Núria Martín +* Jordi Ballester +* Lois Rilo + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-Nuria Martin | image:: https://github.com/Nuria Martin .png?size=40px + :target: https://github.com/Nuria Martin + :alt: Nuria Martin +.. |maintainer-Jordi Ballester | image:: https://github.com/Jordi Ballester .png?size=40px + :target: https://github.com/Jordi Ballester + :alt: Jordi Ballester +.. |maintainer-Lois Rilo | image:: https://github.com/Lois Rilo .png?size=40px + :target: https://github.com/Lois Rilo + :alt: Lois Rilo + +Current `maintainers `__: + +|maintainer-Nuria Martin | |maintainer-Jordi Ballester | |maintainer-Lois Rilo | + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/supplier_calendar/__init__.py b/supplier_calendar/__init__.py new file mode 100644 index 00000000000..d9f9b6d497b --- /dev/null +++ b/supplier_calendar/__init__.py @@ -0,0 +1,3 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import models + diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py new file mode 100644 index 00000000000..eca2c9e0043 --- /dev/null +++ b/supplier_calendar/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2020 ForgeFlow +# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Supplier Calendar", + "summary": "Supplier Calendar", + 'version': '12.0.1.0.0', + "category": "Purchase Management", + "author": "ForgeFlow," + "Odoo Community Association (OCA)", + "maintainers": ["NuriaMForgeFlow"], + "license": "LGPL-3", + 'application': False, + 'installable': True, + 'auto_install': False, + "depends": [ + "purchase_stock", + "resource", + ], + "data": [ + 'views/res_partner_view.xml', + 'views/product_view.xml' + ], +} diff --git a/supplier_calendar/models/__init__.py b/supplier_calendar/models/__init__.py new file mode 100644 index 00000000000..723275adb3d --- /dev/null +++ b/supplier_calendar/models/__init__.py @@ -0,0 +1,6 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import res_partner +from . import product +from . import stock_rule +from . import purchase + diff --git a/supplier_calendar/models/product.py b/supplier_calendar/models/product.py new file mode 100644 index 00000000000..3260862db3e --- /dev/null +++ b/supplier_calendar/models/product.py @@ -0,0 +1,12 @@ +# Copyright 2020 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models, fields + + +class ProductSupplierInfo(models.Model): + _inherit = "product.supplierinfo" + + delay_calendar_type = fields.Selection( + related='name.delay_calendar_type', + readonly=True) diff --git a/supplier_calendar/models/purchase.py b/supplier_calendar/models/purchase.py new file mode 100644 index 00000000000..483f13aa20c --- /dev/null +++ b/supplier_calendar/models/purchase.py @@ -0,0 +1,23 @@ +# Copyright 2020 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models, api +from datetime import datetime + + +class PurchaseOrderLine(models.Model): + _inherit = 'purchase.order.line' + + @api.model + def _get_date_planned(self, seller, po=False): + date_planned = super(PurchaseOrderLine, self)._get_date_planned(seller, + po) + if seller.name.factory_calendar_id: + date_order = po.date_order if po else self.order_id.date_order + if date_order: + date_planned = seller.name.supplier_plan_days(date_order, + seller.delay) + else: + date_planned = seller.name.supplier_plan_days(datetime.today(), + seller.delay) + return date_planned diff --git a/supplier_calendar/models/res_partner.py b/supplier_calendar/models/res_partner.py new file mode 100644 index 00000000000..bda5d2233a6 --- /dev/null +++ b/supplier_calendar/models/res_partner.py @@ -0,0 +1,50 @@ +# Copyright 2020 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from datetime import datetime, timedelta + +from odoo import models, api, fields + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + factory_calendar_id = fields.Many2one(comodel_name='resource.calendar') + delay_calendar_type = fields.Selection([ + ('natural', 'Natural days'), + ('supplier_calendar', 'Supplier Calendar'), + ], default='natural', required=True) + + @api.onchange('delay_calendar_type') + def _onchange_delay_calendar_type(self): + for rec in self: + if rec.delay_calendar_type == 'natural': + rec.factory_calendar_id = False + + def supplier_plan_days(self, date_from, delta): + """Helper method to calculate supplier delay based on its + working days (if set). + + :param datetime date_from: reference date. + :param integer delta: delay established. + :return: datetime: resulting date. + """ + self.ensure_one() + if not isinstance(date_from, datetime): + date_from = fields.Datetime.to_datetime(date_from) + if delta == 0: + return date_from + if self.factory_calendar_id: + if delta < 0: + # We force the date planned to be at the beginning of the day. + # So no work intervals are found in the reference date. + dt_planned = date_from.replace(hour=0) + else: + # We force the date planned at the end of the day. + dt_planned = date_from.replace(hour=23) + date_result = self.factory_calendar_id.plan_days(delta, + dt_planned, + compute_leaves=True) + else: + date_result = date_from + timedelta(days=delta) + return date_result diff --git a/supplier_calendar/models/stock_rule.py b/supplier_calendar/models/stock_rule.py new file mode 100644 index 00000000000..c56f1390b81 --- /dev/null +++ b/supplier_calendar/models/stock_rule.py @@ -0,0 +1,25 @@ +# Copyright 2020 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models + + +class StockRule(models.Model): + _inherit = 'stock.rule' + + def _get_purchase_order_date(self, product_id, product_qty, product_uom, + values, partner, schedule_date): + res = super()._get_purchase_order_date( + product_id, + product_qty, product_uom, + values, partner, schedule_date) + seller = product_id.with_context(force_company=values[ + 'company_id'].id)._select_seller(partner_id=partner, + quantity=product_qty, + date=schedule_date and + schedule_date.date(), + uom_id=product_uom) + if seller: + delay = -1 * seller.delay + res = seller.name.supplier_plan_days(schedule_date, delay) + return res diff --git a/supplier_calendar/readme/CONFIGURE.rst b/supplier_calendar/readme/CONFIGURE.rst new file mode 100644 index 00000000000..b69f936df29 --- /dev/null +++ b/supplier_calendar/readme/CONFIGURE.rst @@ -0,0 +1,9 @@ +* Go to *Settings* and activate the developer mode. + +* Go to *Settings > Technical > Resource > Working Time* and define your + resource calendar. + +* Go to *Contacts > Sales&Purchases > Purchase > Delay Calendar Type* + and assign Supplier Calendar and in *Factory Closing Days* assign the + Resource Calendar desired. + diff --git a/supplier_calendar/readme/CONTRIBUTORS.rst b/supplier_calendar/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..20c4e69ea5d --- /dev/null +++ b/supplier_calendar/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ + +* Núria Martín +* Jordi Ballester +* Lois Rilo diff --git a/supplier_calendar/readme/DESCRIPTION.rst b/supplier_calendar/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..0c250a6aa20 --- /dev/null +++ b/supplier_calendar/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module adds a Calendar to the ResPartner model. This calendar can then +used as the basis of the proper computation of start/end dates based on the +delivery lead time of the supplier in this and other modules. + +In this module, the calendar is considered in the computation of the schedules +date of a stock picking and in the order date of a purchase order. diff --git a/supplier_calendar/readme/USAGE.rst b/supplier_calendar/readme/USAGE.rst new file mode 100644 index 00000000000..3abc3b3fce8 --- /dev/null +++ b/supplier_calendar/readme/USAGE.rst @@ -0,0 +1,9 @@ +When a picking is created from a purchase order of a supplier, the lead +time used to calculate the scheduled date is computed in natural days. At the +same time, when a purchase order is created due to a a procurement +evaluation, its order date is also computed considering the lead time in +natural days. THis module adds the possibility of expressing the lead time +of a vendor in his own calendar. This way, the order dates of purchase +orders and the scheduled dates of receipts will only take into account the +supplier working days. + diff --git a/supplier_calendar/static/description/icon.png b/supplier_calendar/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT binary patch literal 9455 zcmW++2RxMjAAjx~&dlBk9S+%}OXg)AGE&Cb*&}d0jUxM@u(PQx^-s)697TX`ehR4?GS^qbkof1cslKgkU)h65qZ9Oc=ml_0temigYLJfnz{IDzUf>bGs4N!v3=Z3jMq&A#7%rM5eQ#dc?k~! zVpnB`o+K7|Al`Q_U;eD$B zfJtP*jH`siUq~{KE)`jP2|#TUEFGRryE2`i0**z#*^6~AI|YzIWy$Cu#CSLW3q=GA z6`?GZymC;dCPk~rBS%eCb`5OLr;RUZ;D`}um=H)BfVIq%7VhiMr)_#G0N#zrNH|__ zc+blN2UAB0=617@>_u;MPHN;P;N#YoE=)R#i$k_`UAA>WWCcEVMh~L_ zj--gtp&|K1#58Yz*AHCTMziU1Jzt_jG0I@qAOHsk$2}yTmVkBp_eHuY$A9)>P6o~I z%aQ?!(GqeQ-Y+b0I(m9pwgi(IIZZzsbMv+9w{PFtd_<_(LA~0H(xz{=FhLB@(1&qHA5EJw1>>=%q2f&^X>IQ{!GJ4e9U z&KlB)z(84HmNgm2hg2C0>WM{E(DdPr+EeU_N@57;PC2&DmGFW_9kP&%?X4}+xWi)( z;)z%wI5>D4a*5XwD)P--sPkoY(a~WBw;E~AW`Yue4kFa^LM3X`8x|}ZUeMnqr}>kH zG%WWW>3ml$Yez?i%)2pbKPI7?5o?hydokgQyZsNEr{a|mLdt;X2TX(#B1j35xPnPW z*bMSSOauW>o;*=kO8ojw91VX!qoOQb)zHJ!odWB}d+*K?#sY_jqPdg{Sm2HdYzdEx zOGVPhVRTGPtv0o}RfVP;Nd(|CB)I;*t&QO8h zFfekr30S!-LHmV_Su-W+rEwYXJ^;6&3|L$mMC8*bQptyOo9;>Qb9Q9`ySe3%V$A*9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literal 0 HcmV?d00001 diff --git a/supplier_calendar/static/description/index.html b/supplier_calendar/static/description/index.html new file mode 100644 index 00000000000..b40f6c58d55 --- /dev/null +++ b/supplier_calendar/static/description/index.html @@ -0,0 +1,451 @@ + + + + + + +Supplier Calendar + + + +
+

Supplier Calendar

+ + +

Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

This module adds a Calendar to the ResPartner model. This calendar can then +used as the basis of the proper computation of start/end dates based on the +delivery lead time of the supplier in this and other modules.

+

In this module, the calendar is considered in the computation of the schedules +date of a stock picking and in the order date of a purchase order.

+

Table of contents

+ +
+

Configuration

+
    +
  • Go to Settings and activate the developer mode.
  • +
  • Go to Settings > Technical > Resource > Working Time and define your +resource calendar.
  • +
  • Go to Contacts > Sales&Purchases > Purchase > Delay Calendar Type +and assign Supplier Calendar and in Factory Closing Days assign the +Resource Calendar desired.
  • +
+
+
+

Usage

+

When a picking is created from a purchase order of a supplier, the lead +time used to calculate the scheduled date is computed in natural days. At the +same time, when a purchase order is created due to a a procurement +evaluation, its order date is also computed considering the lead time in +natural days. THis module adds the possibility of expressing the lead time +of a vendor in his own calendar. This way, the order dates of purchase +orders and the scheduled dates of receipts will only take into account the +supplier working days.

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainers:

+

Nuria Martin <nuria.martin@forgeflow.com> Jordi Ballester <jordi.ballester@forgeflow.com> Lois Rilo <lois.rilo@forgeflow.com>

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/supplier_calendar/tests/__init__.py b/supplier_calendar/tests/__init__.py new file mode 100644 index 00000000000..f73ec27681c --- /dev/null +++ b/supplier_calendar/tests/__init__.py @@ -0,0 +1,2 @@ +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). +from . import test_supplier_calendar diff --git a/supplier_calendar/tests/test_supplier_calendar.py b/supplier_calendar/tests/test_supplier_calendar.py new file mode 100644 index 00000000000..b867a41946f --- /dev/null +++ b/supplier_calendar/tests/test_supplier_calendar.py @@ -0,0 +1,107 @@ +# Copyright 2020 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestStockWarehouseCalendar(TransactionCase): + + def setUp(self): + super(TestStockWarehouseCalendar, self).setUp() + self.move_obj = self.env['stock.move'] + self.company = self.env.ref('base.main_company') + self.company_partner = self.env.ref('base.main_partner') + self.calendar = self.env.ref('resource.resource_calendar_std') + self.supplier_info = self.env['product.supplierinfo'] + self.PurchaseOrder = self.env['purchase.order'] + self.PurchaseOrderLine = self.env['purchase.order.line'] + self.stock_location = self.env['ir.model.data'].xmlid_to_object( + 'stock.stock_location_stock') + self.customer_location = self.env['ir.model.data'].xmlid_to_object( + 'stock.stock_location_customers') + self.picking_type_out = self.env['ir.model.data'].xmlid_to_object( + 'stock.picking_type_out') + self.route_buy = self.env.ref('purchase_stock.route_warehouse0_buy').id + + # Create product + self.product = self.env['product.product'].create({ + 'name': 'test product', + 'default_code': 'PRD', + 'type': 'product', + 'route_ids': [(4, self.ref('stock.route_warehouse0_mto')), + (4, self.ref('purchase_stock.route_warehouse0_buy'))] + }) + + # Partner and Supplierinfo + self.company_partner.write({ + 'delay_calendar_type': 'supplier_calendar', + 'factory_calendar_id': self.calendar.id + + }) + self.seller_01 = self.supplier_info.create({ + 'name': self.company_partner.id, + "product_id": self.product.id, + 'product_tmpl_id': self.product.product_tmpl_id.id, + 'delay': 3 + }) + + def test_01_purchase_order_with_supplier_calendar(self): + # Create a customer picking + customer_picking = self.env['stock.picking'].create({ + 'location_id': self.stock_location.id, + 'location_dest_id': self.customer_location.id, + 'partner_id': self.company_partner.id, + 'picking_type_id': self.picking_type_out.id, + }) + + customer_move = self.env['stock.move'].create({ + 'name': 'move out', + 'location_id': self.stock_location.id, + 'location_dest_id': self.customer_location.id, + 'product_id': self.product.id, + 'product_uom': self.product.uom_id.id, + 'product_uom_qty': 80.0, + 'procure_method': 'make_to_order', + 'picking_id': customer_picking.id, + 'date_expected': '2097-01-14 09:00:00' # Monday + }) + + customer_move._action_confirm() + + purchase_order = self.env['purchase.order'].search( + [('partner_id', '=', self.company_partner.id)]) + self.assertTrue(purchase_order, 'No purchase order created.') + date_order = fields.Date.to_date(purchase_order.date_order) + wednesday = fields.Date.to_date('2097-01-09 09:00:00') + self.assertEqual(date_order, wednesday) # Wednesday + + def test_02_purchase_order_supplier_calendar_global_leaves(self): + # Global leaves + self.calendar.write({ + 'global_leave_ids': [ + (0, False, { + 'name': 'Test', + 'date_from': '2097-01-14', # Monday + 'date_to': '2097-01-19', # Saturday + }), + ], + }) + + reference = "2097-01-14 09:00:00" # Monday + # With calendar + result = self.company_partner.supplier_plan_days(reference, 3).date() + next_wednesday = fields.Date.to_date("2097-01-23") + self.assertEquals(result, next_wednesday) + reference_2 = "2097-01-11 12:00:00" # friday + result = self.company_partner.supplier_plan_days(reference_2, 3).date() + self.assertEquals(result, next_wednesday) + # Without calendar + self.company_partner.write({ + 'delay_calendar_type': 'natural', + 'factory_calendar_id': False + }) + reference_3 = "2097-01-25 12:00:00" # friday + result = self.company_partner.supplier_plan_days(reference_3, 3).date() + monday = fields.Date.to_date("2097-01-28") + self.assertEquals(result, monday) diff --git a/supplier_calendar/views/product_view.xml b/supplier_calendar/views/product_view.xml new file mode 100644 index 00000000000..e9b16e93220 --- /dev/null +++ b/supplier_calendar/views/product_view.xml @@ -0,0 +1,15 @@ + + + + + product.supplierinfo.form.view + product.supplierinfo + + + + + + + + diff --git a/supplier_calendar/views/res_partner_view.xml b/supplier_calendar/views/res_partner_view.xml new file mode 100644 index 00000000000..ef4e6b61a71 --- /dev/null +++ b/supplier_calendar/views/res_partner_view.xml @@ -0,0 +1,20 @@ + + + + + partner.factory.calendar.form + res.partner + + + + + + + + + + + From 77653425eedc46d250e0b94fa56dbc3741e15d88 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Tue, 7 Apr 2020 09:24:40 +0000 Subject: [PATCH 02/13] [UPD] Update supplier_calendar.pot --- supplier_calendar/i18n/supplier_calendar.pot | 58 ++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 supplier_calendar/i18n/supplier_calendar.pot diff --git a/supplier_calendar/i18n/supplier_calendar.pot b/supplier_calendar/i18n/supplier_calendar.pot new file mode 100644 index 00000000000..c176385146a --- /dev/null +++ b/supplier_calendar/i18n/supplier_calendar.pot @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * supplier_calendar +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: supplier_calendar +#: model:ir.model,name:supplier_calendar.model_res_partner +msgid "Contact" +msgstr "" + +#. module: supplier_calendar +#: model:ir.model.fields,field_description:supplier_calendar.field_product_supplierinfo__delay_calendar_type +#: model:ir.model.fields,field_description:supplier_calendar.field_res_partner__delay_calendar_type +#: model:ir.model.fields,field_description:supplier_calendar.field_res_users__delay_calendar_type +msgid "Delay Calendar Type" +msgstr "" + +#. module: supplier_calendar +#: model:ir.model.fields,field_description:supplier_calendar.field_res_partner__factory_calendar_id +#: model:ir.model.fields,field_description:supplier_calendar.field_res_users__factory_calendar_id +msgid "Factory Calendar" +msgstr "" + +#. module: supplier_calendar +#: selection:res.partner,delay_calendar_type:0 +msgid "Natural days" +msgstr "" + +#. module: supplier_calendar +#: model:ir.model,name:supplier_calendar.model_purchase_order_line +msgid "Purchase Order Line" +msgstr "" + +#. module: supplier_calendar +#: model:ir.model,name:supplier_calendar.model_stock_rule +msgid "Stock Rule" +msgstr "" + +#. module: supplier_calendar +#: selection:res.partner,delay_calendar_type:0 +msgid "Supplier Calendar" +msgstr "" + +#. module: supplier_calendar +#: model:ir.model,name:supplier_calendar.model_product_supplierinfo +msgid "Supplier Pricelist" +msgstr "" + From 34951ac9641ed1d322dfcfeb8537bbadeb25fee3 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 7 Apr 2020 10:07:00 +0000 Subject: [PATCH 03/13] [UPD] README.rst --- supplier_calendar/README.rst | 17 ++++++----------- supplier_calendar/static/description/index.html | 4 ++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/supplier_calendar/README.rst b/supplier_calendar/README.rst index 245be061dd5..55274057b91 100644 --- a/supplier_calendar/README.rst +++ b/supplier_calendar/README.rst @@ -84,6 +84,7 @@ Authors Contributors ~~~~~~~~~~~~ + * Núria Martín * Jordi Ballester * Lois Rilo @@ -101,19 +102,13 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -.. |maintainer-Nuria Martin | image:: https://github.com/Nuria Martin .png?size=40px - :target: https://github.com/Nuria Martin - :alt: Nuria Martin -.. |maintainer-Jordi Ballester | image:: https://github.com/Jordi Ballester .png?size=40px - :target: https://github.com/Jordi Ballester - :alt: Jordi Ballester -.. |maintainer-Lois Rilo | image:: https://github.com/Lois Rilo .png?size=40px - :target: https://github.com/Lois Rilo - :alt: Lois Rilo +.. |maintainer-NuriaMForgeFlow| image:: https://github.com/NuriaMForgeFlow.png?size=40px + :target: https://github.com/NuriaMForgeFlow + :alt: NuriaMForgeFlow -Current `maintainers `__: +Current `maintainer `__: -|maintainer-Nuria Martin | |maintainer-Jordi Ballester | |maintainer-Lois Rilo | +|maintainer-NuriaMForgeFlow| This module is part of the `OCA/purchase-workflow `_ project on GitHub. diff --git a/supplier_calendar/static/description/index.html b/supplier_calendar/static/description/index.html index b40f6c58d55..3d55defa153 100644 --- a/supplier_calendar/static/description/index.html +++ b/supplier_calendar/static/description/index.html @@ -440,8 +440,8 @@

Maintainers

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

Current maintainers:

-

Nuria Martin <nuria.martin@forgeflow.com> Jordi Ballester <jordi.ballester@forgeflow.com> Lois Rilo <lois.rilo@forgeflow.com>

+

Current maintainer:

+

NuriaMForgeFlow

This module is part of the OCA/purchase-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From ca59d6d847e183e9b34518c2f836e96034bce426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mart=C3=ADn=20Xifr=C3=A9?= Date: Mon, 4 May 2020 16:15:09 +0200 Subject: [PATCH 04/13] [IMP] : black, isort, prettier --- supplier_calendar/__init__.py | 1 - supplier_calendar/__manifest__.py | 21 +-- supplier_calendar/models/__init__.py | 1 - supplier_calendar/models/product.py | 6 +- supplier_calendar/models/purchase.py | 16 +- supplier_calendar/models/res_partner.py | 25 +-- supplier_calendar/models/stock_rule.py | 26 +-- supplier_calendar/readme/CONFIGURE.rst | 1 - supplier_calendar/readme/USAGE.rst | 1 - .../tests/test_supplier_calendar.py | 153 ++++++++++-------- supplier_calendar/views/product_view.xml | 8 +- supplier_calendar/views/res_partner_view.xml | 20 +-- 12 files changed, 146 insertions(+), 133 deletions(-) diff --git a/supplier_calendar/__init__.py b/supplier_calendar/__init__.py index d9f9b6d497b..5d9d2438128 100644 --- a/supplier_calendar/__init__.py +++ b/supplier_calendar/__init__.py @@ -1,3 +1,2 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models - diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py index eca2c9e0043..5ba5afc73b6 100644 --- a/supplier_calendar/__manifest__.py +++ b/supplier_calendar/__manifest__.py @@ -3,21 +3,14 @@ { "name": "Supplier Calendar", "summary": "Supplier Calendar", - 'version': '12.0.1.0.0', + "version": "12.0.1.0.0", "category": "Purchase Management", - "author": "ForgeFlow," - "Odoo Community Association (OCA)", + "author": "ForgeFlow," "Odoo Community Association (OCA)", "maintainers": ["NuriaMForgeFlow"], "license": "LGPL-3", - 'application': False, - 'installable': True, - 'auto_install': False, - "depends": [ - "purchase_stock", - "resource", - ], - "data": [ - 'views/res_partner_view.xml', - 'views/product_view.xml' - ], + "application": False, + "installable": True, + "auto_install": False, + "depends": ["purchase_stock", "resource",], + "data": ["views/res_partner_view.xml", "views/product_view.xml"], } diff --git a/supplier_calendar/models/__init__.py b/supplier_calendar/models/__init__.py index 723275adb3d..9fdc3838d39 100644 --- a/supplier_calendar/models/__init__.py +++ b/supplier_calendar/models/__init__.py @@ -3,4 +3,3 @@ from . import product from . import stock_rule from . import purchase - diff --git a/supplier_calendar/models/product.py b/supplier_calendar/models/product.py index 3260862db3e..6ee662654eb 100644 --- a/supplier_calendar/models/product.py +++ b/supplier_calendar/models/product.py @@ -1,12 +1,12 @@ # Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import fields, models class ProductSupplierInfo(models.Model): _inherit = "product.supplierinfo" delay_calendar_type = fields.Selection( - related='name.delay_calendar_type', - readonly=True) + related="name.delay_calendar_type", readonly=True + ) diff --git a/supplier_calendar/models/purchase.py b/supplier_calendar/models/purchase.py index 483f13aa20c..c67d929735b 100644 --- a/supplier_calendar/models/purchase.py +++ b/supplier_calendar/models/purchase.py @@ -1,23 +1,23 @@ # Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from odoo import models, api from datetime import datetime +from odoo import api, models + class PurchaseOrderLine(models.Model): - _inherit = 'purchase.order.line' + _inherit = "purchase.order.line" @api.model def _get_date_planned(self, seller, po=False): - date_planned = super(PurchaseOrderLine, self)._get_date_planned(seller, - po) + date_planned = super(PurchaseOrderLine, self)._get_date_planned(seller, po) if seller.name.factory_calendar_id: date_order = po.date_order if po else self.order_id.date_order if date_order: - date_planned = seller.name.supplier_plan_days(date_order, - seller.delay) + date_planned = seller.name.supplier_plan_days(date_order, seller.delay) else: - date_planned = seller.name.supplier_plan_days(datetime.today(), - seller.delay) + date_planned = seller.name.supplier_plan_days( + datetime.today(), seller.delay + ) return date_planned diff --git a/supplier_calendar/models/res_partner.py b/supplier_calendar/models/res_partner.py index bda5d2233a6..b0174104f3e 100644 --- a/supplier_calendar/models/res_partner.py +++ b/supplier_calendar/models/res_partner.py @@ -3,22 +3,23 @@ from datetime import datetime, timedelta -from odoo import models, api, fields +from odoo import api, fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" - factory_calendar_id = fields.Many2one(comodel_name='resource.calendar') - delay_calendar_type = fields.Selection([ - ('natural', 'Natural days'), - ('supplier_calendar', 'Supplier Calendar'), - ], default='natural', required=True) + factory_calendar_id = fields.Many2one(comodel_name="resource.calendar") + delay_calendar_type = fields.Selection( + [("natural", "Natural days"), ("supplier_calendar", "Supplier Calendar"),], + default="natural", + required=True, + ) - @api.onchange('delay_calendar_type') + @api.onchange("delay_calendar_type") def _onchange_delay_calendar_type(self): for rec in self: - if rec.delay_calendar_type == 'natural': + if rec.delay_calendar_type == "natural": rec.factory_calendar_id = False def supplier_plan_days(self, date_from, delta): @@ -42,9 +43,9 @@ def supplier_plan_days(self, date_from, delta): else: # We force the date planned at the end of the day. dt_planned = date_from.replace(hour=23) - date_result = self.factory_calendar_id.plan_days(delta, - dt_planned, - compute_leaves=True) + date_result = self.factory_calendar_id.plan_days( + delta, dt_planned, compute_leaves=True + ) else: date_result = date_from + timedelta(days=delta) return date_result diff --git a/supplier_calendar/models/stock_rule.py b/supplier_calendar/models/stock_rule.py index c56f1390b81..8c84f574132 100644 --- a/supplier_calendar/models/stock_rule.py +++ b/supplier_calendar/models/stock_rule.py @@ -5,20 +5,22 @@ class StockRule(models.Model): - _inherit = 'stock.rule' + _inherit = "stock.rule" - def _get_purchase_order_date(self, product_id, product_qty, product_uom, - values, partner, schedule_date): + def _get_purchase_order_date( + self, product_id, product_qty, product_uom, values, partner, schedule_date + ): res = super()._get_purchase_order_date( - product_id, - product_qty, product_uom, - values, partner, schedule_date) - seller = product_id.with_context(force_company=values[ - 'company_id'].id)._select_seller(partner_id=partner, - quantity=product_qty, - date=schedule_date and - schedule_date.date(), - uom_id=product_uom) + product_id, product_qty, product_uom, values, partner, schedule_date + ) + seller = product_id.with_context( + force_company=values["company_id"].id + )._select_seller( + partner_id=partner, + quantity=product_qty, + date=schedule_date and schedule_date.date(), + uom_id=product_uom, + ) if seller: delay = -1 * seller.delay res = seller.name.supplier_plan_days(schedule_date, delay) diff --git a/supplier_calendar/readme/CONFIGURE.rst b/supplier_calendar/readme/CONFIGURE.rst index b69f936df29..2174bb6fd39 100644 --- a/supplier_calendar/readme/CONFIGURE.rst +++ b/supplier_calendar/readme/CONFIGURE.rst @@ -6,4 +6,3 @@ * Go to *Contacts > Sales&Purchases > Purchase > Delay Calendar Type* and assign Supplier Calendar and in *Factory Closing Days* assign the Resource Calendar desired. - diff --git a/supplier_calendar/readme/USAGE.rst b/supplier_calendar/readme/USAGE.rst index 3abc3b3fce8..02daadd61ad 100644 --- a/supplier_calendar/readme/USAGE.rst +++ b/supplier_calendar/readme/USAGE.rst @@ -6,4 +6,3 @@ natural days. THis module adds the possibility of expressing the lead time of a vendor in his own calendar. This way, the order dates of purchase orders and the scheduled dates of receipts will only take into account the supplier working days. - diff --git a/supplier_calendar/tests/test_supplier_calendar.py b/supplier_calendar/tests/test_supplier_calendar.py index b867a41946f..4bf67241b91 100644 --- a/supplier_calendar/tests/test_supplier_calendar.py +++ b/supplier_calendar/tests/test_supplier_calendar.py @@ -6,87 +6,107 @@ class TestStockWarehouseCalendar(TransactionCase): - def setUp(self): super(TestStockWarehouseCalendar, self).setUp() - self.move_obj = self.env['stock.move'] - self.company = self.env.ref('base.main_company') - self.company_partner = self.env.ref('base.main_partner') - self.calendar = self.env.ref('resource.resource_calendar_std') - self.supplier_info = self.env['product.supplierinfo'] - self.PurchaseOrder = self.env['purchase.order'] - self.PurchaseOrderLine = self.env['purchase.order.line'] - self.stock_location = self.env['ir.model.data'].xmlid_to_object( - 'stock.stock_location_stock') - self.customer_location = self.env['ir.model.data'].xmlid_to_object( - 'stock.stock_location_customers') - self.picking_type_out = self.env['ir.model.data'].xmlid_to_object( - 'stock.picking_type_out') - self.route_buy = self.env.ref('purchase_stock.route_warehouse0_buy').id + self.move_obj = self.env["stock.move"] + self.company = self.env.ref("base.main_company") + self.company_partner = self.env.ref("base.main_partner") + self.calendar = self.env.ref("resource.resource_calendar_std") + self.supplier_info = self.env["product.supplierinfo"] + self.PurchaseOrder = self.env["purchase.order"] + self.PurchaseOrderLine = self.env["purchase.order.line"] + self.stock_location = self.env["ir.model.data"].xmlid_to_object( + "stock.stock_location_stock" + ) + self.customer_location = self.env["ir.model.data"].xmlid_to_object( + "stock.stock_location_customers" + ) + self.picking_type_out = self.env["ir.model.data"].xmlid_to_object( + "stock.picking_type_out" + ) + self.route_buy = self.env.ref("purchase_stock.route_warehouse0_buy").id # Create product - self.product = self.env['product.product'].create({ - 'name': 'test product', - 'default_code': 'PRD', - 'type': 'product', - 'route_ids': [(4, self.ref('stock.route_warehouse0_mto')), - (4, self.ref('purchase_stock.route_warehouse0_buy'))] - }) + self.product = self.env["product.product"].create( + { + "name": "test product", + "default_code": "PRD", + "type": "product", + "route_ids": [ + (4, self.ref("stock.route_warehouse0_mto")), + (4, self.ref("purchase_stock.route_warehouse0_buy")), + ], + } + ) # Partner and Supplierinfo - self.company_partner.write({ - 'delay_calendar_type': 'supplier_calendar', - 'factory_calendar_id': self.calendar.id - - }) - self.seller_01 = self.supplier_info.create({ - 'name': self.company_partner.id, - "product_id": self.product.id, - 'product_tmpl_id': self.product.product_tmpl_id.id, - 'delay': 3 - }) + self.company_partner.write( + { + "delay_calendar_type": "supplier_calendar", + "factory_calendar_id": self.calendar.id, + } + ) + self.seller_01 = self.supplier_info.create( + { + "name": self.company_partner.id, + "product_id": self.product.id, + "product_tmpl_id": self.product.product_tmpl_id.id, + "delay": 3, + } + ) def test_01_purchase_order_with_supplier_calendar(self): # Create a customer picking - customer_picking = self.env['stock.picking'].create({ - 'location_id': self.stock_location.id, - 'location_dest_id': self.customer_location.id, - 'partner_id': self.company_partner.id, - 'picking_type_id': self.picking_type_out.id, - }) + customer_picking = self.env["stock.picking"].create( + { + "location_id": self.stock_location.id, + "location_dest_id": self.customer_location.id, + "partner_id": self.company_partner.id, + "picking_type_id": self.picking_type_out.id, + } + ) - customer_move = self.env['stock.move'].create({ - 'name': 'move out', - 'location_id': self.stock_location.id, - 'location_dest_id': self.customer_location.id, - 'product_id': self.product.id, - 'product_uom': self.product.uom_id.id, - 'product_uom_qty': 80.0, - 'procure_method': 'make_to_order', - 'picking_id': customer_picking.id, - 'date_expected': '2097-01-14 09:00:00' # Monday - }) + customer_move = self.env["stock.move"].create( + { + "name": "move out", + "location_id": self.stock_location.id, + "location_dest_id": self.customer_location.id, + "product_id": self.product.id, + "product_uom": self.product.uom_id.id, + "product_uom_qty": 80.0, + "procure_method": "make_to_order", + "picking_id": customer_picking.id, + "date_expected": "2097-01-14 09:00:00", # Monday + } + ) customer_move._action_confirm() - purchase_order = self.env['purchase.order'].search( - [('partner_id', '=', self.company_partner.id)]) - self.assertTrue(purchase_order, 'No purchase order created.') + purchase_order = self.env["purchase.order"].search( + [("partner_id", "=", self.company_partner.id)] + ) + self.assertTrue(purchase_order, "No purchase order created.") date_order = fields.Date.to_date(purchase_order.date_order) - wednesday = fields.Date.to_date('2097-01-09 09:00:00') + wednesday = fields.Date.to_date("2097-01-09 09:00:00") self.assertEqual(date_order, wednesday) # Wednesday def test_02_purchase_order_supplier_calendar_global_leaves(self): # Global leaves - self.calendar.write({ - 'global_leave_ids': [ - (0, False, { - 'name': 'Test', - 'date_from': '2097-01-14', # Monday - 'date_to': '2097-01-19', # Saturday - }), - ], - }) + self.calendar.write( + { + "global_leave_ids": [ + ( + 0, + False, + { + "name": "Test", + "date_from": "2097-01-14", # Monday + "date_to": "2097-01-19", # Saturday + }, + ), + ], + } + ) reference = "2097-01-14 09:00:00" # Monday # With calendar @@ -97,10 +117,9 @@ def test_02_purchase_order_supplier_calendar_global_leaves(self): result = self.company_partner.supplier_plan_days(reference_2, 3).date() self.assertEquals(result, next_wednesday) # Without calendar - self.company_partner.write({ - 'delay_calendar_type': 'natural', - 'factory_calendar_id': False - }) + self.company_partner.write( + {"delay_calendar_type": "natural", "factory_calendar_id": False} + ) reference_3 = "2097-01-25 12:00:00" # friday result = self.company_partner.supplier_plan_days(reference_3, 3).date() monday = fields.Date.to_date("2097-01-28") diff --git a/supplier_calendar/views/product_view.xml b/supplier_calendar/views/product_view.xml index e9b16e93220..bd7ee590fcc 100644 --- a/supplier_calendar/views/product_view.xml +++ b/supplier_calendar/views/product_view.xml @@ -1,14 +1,14 @@ - + - + product.supplierinfo.form.view product.supplierinfo - + - + diff --git a/supplier_calendar/views/res_partner_view.xml b/supplier_calendar/views/res_partner_view.xml index ef4e6b61a71..c0891c0966c 100644 --- a/supplier_calendar/views/res_partner_view.xml +++ b/supplier_calendar/views/res_partner_view.xml @@ -1,20 +1,22 @@ - + partner.factory.calendar.form res.partner - + - - - + + + - - From 3c9bc945fbee1b54490a69ac51032f44f96cd206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=BAria=20Mart=C3=ADn=20Xifr=C3=A9?= Date: Mon, 4 May 2020 16:17:33 +0200 Subject: [PATCH 05/13] [13.0][MIG] supplier_calendar --- supplier_calendar/__manifest__.py | 4 ++-- supplier_calendar/models/res_partner.py | 2 +- supplier_calendar/models/stock_rule.py | 31 +++++++++++-------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py index 5ba5afc73b6..141edc946ac 100644 --- a/supplier_calendar/__manifest__.py +++ b/supplier_calendar/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Supplier Calendar", "summary": "Supplier Calendar", - "version": "12.0.1.0.0", + "version": "13.0.1.0.0", "category": "Purchase Management", "author": "ForgeFlow," "Odoo Community Association (OCA)", "maintainers": ["NuriaMForgeFlow"], @@ -11,6 +11,6 @@ "application": False, "installable": True, "auto_install": False, - "depends": ["purchase_stock", "resource",], + "depends": ["purchase_stock", "resource"], "data": ["views/res_partner_view.xml", "views/product_view.xml"], } diff --git a/supplier_calendar/models/res_partner.py b/supplier_calendar/models/res_partner.py index b0174104f3e..1255e51f4f1 100644 --- a/supplier_calendar/models/res_partner.py +++ b/supplier_calendar/models/res_partner.py @@ -11,7 +11,7 @@ class ResPartner(models.Model): factory_calendar_id = fields.Many2one(comodel_name="resource.calendar") delay_calendar_type = fields.Selection( - [("natural", "Natural days"), ("supplier_calendar", "Supplier Calendar"),], + [("natural", "Natural days"), ("supplier_calendar", "Supplier Calendar")], default="natural", required=True, ) diff --git a/supplier_calendar/models/stock_rule.py b/supplier_calendar/models/stock_rule.py index 8c84f574132..285c49747f6 100644 --- a/supplier_calendar/models/stock_rule.py +++ b/supplier_calendar/models/stock_rule.py @@ -1,27 +1,24 @@ # Copyright 2020 ForgeFlow S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) -from odoo import models +from dateutil.relativedelta import relativedelta + +from odoo import fields, models class StockRule(models.Model): _inherit = "stock.rule" - def _get_purchase_order_date( - self, product_id, product_qty, product_uom, values, partner, schedule_date - ): - res = super()._get_purchase_order_date( - product_id, product_qty, product_uom, values, partner, schedule_date - ) - seller = product_id.with_context( - force_company=values["company_id"].id - )._select_seller( - partner_id=partner, - quantity=product_qty, - date=schedule_date and schedule_date.date(), - uom_id=product_uom, + def _prepare_purchase_order(self, company_id, origins, values): + res = super()._prepare_purchase_order(company_id, origins, values) + dates = [fields.Datetime.from_string(value["date_planned"]) for value in values] + values = values[0] + partner = values["supplier"].name + procurement_date_planned = min(dates) + schedule_date = procurement_date_planned - relativedelta( + days=company_id.po_lead ) - if seller: - delay = -1 * seller.delay - res = seller.name.supplier_plan_days(schedule_date, delay) + delay = -1 * values["supplier"].delay + purchase_date = partner.supplier_plan_days(schedule_date, delay) + res["date_order"] = purchase_date return res From 0e2b7213cd50177f6b1ee474df2c0409668f4ba6 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Mon, 18 May 2020 11:34:10 +0000 Subject: [PATCH 06/13] [UPD] Update supplier_calendar.pot --- supplier_calendar/i18n/supplier_calendar.pot | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/supplier_calendar/i18n/supplier_calendar.pot b/supplier_calendar/i18n/supplier_calendar.pot index c176385146a..a8ff24274eb 100644 --- a/supplier_calendar/i18n/supplier_calendar.pot +++ b/supplier_calendar/i18n/supplier_calendar.pot @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * supplier_calendar +# * supplier_calendar # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -32,7 +32,7 @@ msgid "Factory Calendar" msgstr "" #. module: supplier_calendar -#: selection:res.partner,delay_calendar_type:0 +#: model:ir.model.fields.selection,name:supplier_calendar.selection__res_partner__delay_calendar_type__natural msgid "Natural days" msgstr "" @@ -47,7 +47,7 @@ msgid "Stock Rule" msgstr "" #. module: supplier_calendar -#: selection:res.partner,delay_calendar_type:0 +#: model:ir.model.fields.selection,name:supplier_calendar.selection__res_partner__delay_calendar_type__supplier_calendar msgid "Supplier Calendar" msgstr "" @@ -55,4 +55,3 @@ msgstr "" #: model:ir.model,name:supplier_calendar.model_product_supplierinfo msgid "Supplier Pricelist" msgstr "" - From 9fd91adbc34b1f38edfe26e05acd77e993cc8937 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Mon, 18 May 2020 11:55:32 +0000 Subject: [PATCH 07/13] [UPD] README.rst --- supplier_calendar/README.rst | 12 +++++------- supplier_calendar/static/description/index.html | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/supplier_calendar/README.rst b/supplier_calendar/README.rst index 55274057b91..3edc27d75c2 100644 --- a/supplier_calendar/README.rst +++ b/supplier_calendar/README.rst @@ -14,13 +14,13 @@ Supplier Calendar :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github - :target: https://github.com/OCA/purchase-workflow/tree/12.0/supplier_calendar + :target: https://github.com/OCA/purchase-workflow/tree/13.0/supplier_calendar :alt: OCA/purchase-workflow .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/purchase-workflow-12-0/purchase-workflow-12-0-supplier_calendar + :target: https://translation.odoo-community.org/projects/purchase-workflow-13-0/purchase-workflow-13-0-supplier_calendar :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/142/12.0 + :target: https://runbot.odoo-community.org/runbot/142/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -49,7 +49,6 @@ Configuration and assign Supplier Calendar and in *Factory Closing Days* assign the Resource Calendar desired. - Usage ===== @@ -62,14 +61,13 @@ of a vendor in his own calendar. This way, the order dates of purchase orders and the scheduled dates of receipts will only take into account the supplier working days. - 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. @@ -110,6 +108,6 @@ Current `maintainer `__: |maintainer-NuriaMForgeFlow| -This module is part of the `OCA/purchase-workflow `_ project on GitHub. +This module is part of the `OCA/purchase-workflow `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/supplier_calendar/static/description/index.html b/supplier_calendar/static/description/index.html index 3d55defa153..51e30a2da3f 100644 --- a/supplier_calendar/static/description/index.html +++ b/supplier_calendar/static/description/index.html @@ -367,7 +367,7 @@

Supplier Calendar

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

+

Beta License: LGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runbot

This module adds a Calendar to the ResPartner model. This calendar can then used as the basis of the proper computation of start/end dates based on the delivery lead time of the supplier in this and other modules.

@@ -414,7 +414,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.

@@ -442,7 +442,7 @@

Maintainers

promote its widespread use.

Current maintainer:

NuriaMForgeFlow

-

This module is part of the OCA/purchase-workflow project on GitHub.

+

This module is part of the OCA/purchase-workflow project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

From ef993f1b3d71dff1b62fc77ecdb22bff088add3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20M=C3=A9quignon?= Date: Thu, 25 Jun 2020 17:11:24 +0200 Subject: [PATCH 08/13] fixup! fixup! fixup! fixup! [ADD] purchase_delays --- supplier_calendar/tests/test_supplier_calendar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/supplier_calendar/tests/test_supplier_calendar.py b/supplier_calendar/tests/test_supplier_calendar.py index 4bf67241b91..6beeb3ec7ba 100644 --- a/supplier_calendar/tests/test_supplier_calendar.py +++ b/supplier_calendar/tests/test_supplier_calendar.py @@ -2,9 +2,11 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). from odoo import fields +from odoo.tests import tagged from odoo.tests.common import TransactionCase +@tagged("post_install", "-at_install") class TestStockWarehouseCalendar(TransactionCase): def setUp(self): super(TestStockWarehouseCalendar, self).setUp() From 6458276b82b4250c33c258a641c79344cf638023 Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 30 Sep 2020 11:53:09 +0200 Subject: [PATCH 09/13] [FIX] Delete empty " " spaces in same string line --- supplier_calendar/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py index 141edc946ac..1ba8a175524 100644 --- a/supplier_calendar/__manifest__.py +++ b/supplier_calendar/__manifest__.py @@ -5,7 +5,7 @@ "summary": "Supplier Calendar", "version": "13.0.1.0.0", "category": "Purchase Management", - "author": "ForgeFlow," "Odoo Community Association (OCA)", + "author": "ForgeFlow, Odoo Community Association (OCA)", "maintainers": ["NuriaMForgeFlow"], "license": "LGPL-3", "application": False, From c04b93753e40dbc9fa2ec35e7d8ade449694b506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marques?= Date: Thu, 5 Aug 2021 09:00:40 +0100 Subject: [PATCH 10/13] [IMP] *: pre-commit execution Fix pre-commit errors by addind the correct `website` key --- supplier_calendar/__manifest__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py index 1ba8a175524..42edbfe273a 100644 --- a/supplier_calendar/__manifest__.py +++ b/supplier_calendar/__manifest__.py @@ -4,6 +4,7 @@ "name": "Supplier Calendar", "summary": "Supplier Calendar", "version": "13.0.1.0.0", + "website": "https://github.com/OCA/purchase-workflow", "category": "Purchase Management", "author": "ForgeFlow, Odoo Community Association (OCA)", "maintainers": ["NuriaMForgeFlow"], From ed1241ddbb0fd55c98b4e69b15539f7175bbf4f6 Mon Sep 17 00:00:00 2001 From: RUS Date: Tue, 2 Nov 2021 11:11:53 +0530 Subject: [PATCH 11/13] [IMP] supplier_calendar: pre-commit execution --- setup/supplier_calendar/odoo/addons/supplier_calendar | 1 + setup/supplier_calendar/setup.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 setup/supplier_calendar/odoo/addons/supplier_calendar create mode 100644 setup/supplier_calendar/setup.py diff --git a/setup/supplier_calendar/odoo/addons/supplier_calendar b/setup/supplier_calendar/odoo/addons/supplier_calendar new file mode 120000 index 00000000000..e7ecab260e1 --- /dev/null +++ b/setup/supplier_calendar/odoo/addons/supplier_calendar @@ -0,0 +1 @@ +../../../../supplier_calendar \ No newline at end of file diff --git a/setup/supplier_calendar/setup.py b/setup/supplier_calendar/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/supplier_calendar/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) From 9d0a55ee85b189e02519dd618fad3a494d4550f1 Mon Sep 17 00:00:00 2001 From: RUS Date: Tue, 2 Nov 2021 11:11:53 +0530 Subject: [PATCH 12/13] [MIG] supplier_calendar: Migration to 14.0 --- supplier_calendar/__manifest__.py | 2 +- supplier_calendar/tests/test_supplier_calendar.py | 8 ++++---- supplier_calendar/views/product_view.xml | 10 ++++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/supplier_calendar/__manifest__.py b/supplier_calendar/__manifest__.py index 42edbfe273a..444f30f4483 100644 --- a/supplier_calendar/__manifest__.py +++ b/supplier_calendar/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Supplier Calendar", "summary": "Supplier Calendar", - "version": "13.0.1.0.0", + "version": "14.0.1.0.0", "website": "https://github.com/OCA/purchase-workflow", "category": "Purchase Management", "author": "ForgeFlow, Odoo Community Association (OCA)", diff --git a/supplier_calendar/tests/test_supplier_calendar.py b/supplier_calendar/tests/test_supplier_calendar.py index 6beeb3ec7ba..2579b84ab4b 100644 --- a/supplier_calendar/tests/test_supplier_calendar.py +++ b/supplier_calendar/tests/test_supplier_calendar.py @@ -78,7 +78,7 @@ def test_01_purchase_order_with_supplier_calendar(self): "product_uom_qty": 80.0, "procure_method": "make_to_order", "picking_id": customer_picking.id, - "date_expected": "2097-01-14 09:00:00", # Monday + "date": "2097-01-14 09:00:00", # Monday } ) @@ -114,10 +114,10 @@ def test_02_purchase_order_supplier_calendar_global_leaves(self): # With calendar result = self.company_partner.supplier_plan_days(reference, 3).date() next_wednesday = fields.Date.to_date("2097-01-23") - self.assertEquals(result, next_wednesday) + self.assertEqual(result, next_wednesday) reference_2 = "2097-01-11 12:00:00" # friday result = self.company_partner.supplier_plan_days(reference_2, 3).date() - self.assertEquals(result, next_wednesday) + self.assertEqual(result, next_wednesday) # Without calendar self.company_partner.write( {"delay_calendar_type": "natural", "factory_calendar_id": False} @@ -125,4 +125,4 @@ def test_02_purchase_order_supplier_calendar_global_leaves(self): reference_3 = "2097-01-25 12:00:00" # friday result = self.company_partner.supplier_plan_days(reference_3, 3).date() monday = fields.Date.to_date("2097-01-28") - self.assertEquals(result, monday) + self.assertEqual(result, monday) diff --git a/supplier_calendar/views/product_view.xml b/supplier_calendar/views/product_view.xml index bd7ee590fcc..1d074e7df6f 100644 --- a/supplier_calendar/views/product_view.xml +++ b/supplier_calendar/views/product_view.xml @@ -12,4 +12,14 @@
+ + product.supplierinfo.supplier_calendar.tree.view + product.supplierinfo + + + + + + +
From 2c02266b8d7e5481720cbcb7af9793a4615048b6 Mon Sep 17 00:00:00 2001 From: DIV Date: Tue, 26 Apr 2022 20:11:48 +0530 Subject: [PATCH 13/13] [IMP][T-02073]supplier_calendar: Add required True in views for delay_calendar_type and remove from py. --- supplier_calendar/models/res_partner.py | 1 - supplier_calendar/views/res_partner_view.xml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/supplier_calendar/models/res_partner.py b/supplier_calendar/models/res_partner.py index 1255e51f4f1..b0d5c212fe9 100644 --- a/supplier_calendar/models/res_partner.py +++ b/supplier_calendar/models/res_partner.py @@ -13,7 +13,6 @@ class ResPartner(models.Model): delay_calendar_type = fields.Selection( [("natural", "Natural days"), ("supplier_calendar", "Supplier Calendar")], default="natural", - required=True, ) @api.onchange("delay_calendar_type") diff --git a/supplier_calendar/views/res_partner_view.xml b/supplier_calendar/views/res_partner_view.xml index c0891c0966c..4535c771343 100644 --- a/supplier_calendar/views/res_partner_view.xml +++ b/supplier_calendar/views/res_partner_view.xml @@ -11,7 +11,7 @@ expr="//page[@name='sales_purchases']//group[@name='purchase']" position="inside" > - +