forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by HviorForgeFlow
- Loading branch information
Showing
21 changed files
with
960 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../supplier_calendar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
================= | ||
Supplier Calendar | ||
================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:429613e871df8a7263098638f7d34c4e1a7ac06a6e9a9da6a81ad2427aa9e6e2 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/14.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-14-0/purchase-workflow-14-0-supplier_calendar | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|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 <https://github.com/OCA/purchase-workflow/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20supplier_calendar%0Aversion:%2014.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. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* ForgeFlow | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
|
||
* Núria Martín <[email protected]> | ||
* Jordi Ballester <[email protected]> | ||
* Lois Rilo <lois.rilo@eforgeflow> | ||
|
||
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-LoisRForgeFlow| image:: https://github.com/LoisRForgeFlow.png?size=40px | ||
:target: https://github.com/LoisRForgeFlow | ||
:alt: LoisRForgeFlow | ||
|
||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__: | ||
|
||
|maintainer-LoisRForgeFlow| | ||
|
||
This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/14.0/supplier_calendar>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2020 ForgeFlow | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Supplier Calendar", | ||
"summary": "Supplier Calendar", | ||
"version": "14.0.1.0.0", | ||
"website": "https://github.com/OCA/purchase-workflow", | ||
"category": "Purchase Management", | ||
"author": "ForgeFlow, Odoo Community Association (OCA)", | ||
"maintainers": ["LoisRForgeFlow"], | ||
"license": "LGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"auto_install": False, | ||
"depends": ["purchase_stock", "resource"], | ||
"data": ["views/res_partner_view.xml", "views/product_view.xml"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * supplier_calendar | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.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 | ||
#: model:ir.model.fields.selection,name:supplier_calendar.selection__res_partner__delay_calendar_type__natural | ||
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 | ||
#: model:ir.model.fields.selection,name:supplier_calendar.selection__res_partner__delay_calendar_type__supplier_calendar | ||
msgid "Supplier Calendar" | ||
msgstr "" | ||
|
||
#. module: supplier_calendar | ||
#: model:ir.model,name:supplier_calendar.model_product_supplierinfo | ||
msgid "Supplier Pricelist" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductSupplierInfo(models.Model): | ||
_inherit = "product.supplierinfo" | ||
|
||
delay_calendar_type = fields.Selection( | ||
related="name.delay_calendar_type", readonly=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from datetime import datetime | ||
|
||
from odoo import api, models | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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 api, fields, models | ||
|
||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2020 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
from dateutil.relativedelta import relativedelta | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class StockRule(models.Model): | ||
_inherit = "stock.rule" | ||
|
||
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 | ||
) | ||
delay = -1 * values["supplier"].delay | ||
purchase_date = partner.supplier_plan_days(schedule_date, delay) | ||
res["date_order"] = purchase_date | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
* Núria Martín <[email protected]> | ||
* Jordi Ballester <[email protected]> | ||
* Lois Rilo <lois.rilo@eforgeflow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.