Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] stock, mrp, purchase_stock: Orderpoint #41115

Open
wants to merge 13 commits into
base: master
from

Conversation

@amoyaux
Copy link
Contributor

amoyaux commented Nov 29, 2019

  • Improve the onboarding on reordering rule with an automatic computation of delay
  • Improve the scheduler performance by running the procurement requests together.
  • Add the days to purchase notion.
  • Merge production from same reordering rules.

More details could be find in each specific commit.

Task 1849912

@robodoo robodoo added the seen 🙂 label Nov 29, 2019
@C3POdoo C3POdoo added the RD label Nov 29, 2019
@robodoo robodoo added the CI 🤖 label Nov 29, 2019
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch from 063f624 to 3ef7cdd Nov 29, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Nov 29, 2019
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch 3 times, most recently from ee182ff to 905e0c1 Nov 29, 2019
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 2, 2019
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch 3 times, most recently from 93a5739 to 2ce03fa Dec 2, 2019
@robodoo robodoo added the CI 🤖 label Dec 2, 2019

def _get_lead_days(self, rules):
delay, delay_description = super(Orderpoint, self)._get_lead_days(rules)
if 'manufacture' not in rules.mapped('action'):

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor
manufature_rule = rules.filtered(lambda r: r.action == 'manufacture')
if manufacture_rule:
...
security_delay = manufature_rule.picking_type_id.company_id.manufacturing_lead```
('orderpoint_id', '!=', False),
('orderpoint_id', '=', 'orderpoint_id' in procurement.values and procurement.values['orderpoint_id'].id),
]
orderpoint = procurement.values.get('orderpoint')

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor

shouldn't be orderpoint_id ?

]
orderpoint = procurement.values.get('orderpoint')
if orderpoint:
domain = expression.AND([domain, ['&',

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor

'&' ?

for pr in self.env['purchase.requisition'].search([('state','=','draft'),('origin','=',op.name)]):
for prline in pr.line_ids.filtered(lambda l: l.product_id.id == op.product_id.id):
for pr in self.env['purchase.requisition'].search([('state', '=', 'draft'), ('origin', '=', op.name)]):
for prline in pr.line_ids.filtered(lambda l: l.product_id.id == op.product_id.id and not prline.move_dest_id):

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor

l.move_dest_id


def _get_lead_days(self, rules):
lead_days, lead_days_description = super(Orderpoint, self)._get_lead_days(rules)
if 'buy' not in rules.mapped('action') or not self.product_id._prepare_sellers(False):

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor

don't think 'False' in _prepare_sellers is mandatory

@@ -298,6 +299,13 @@ def _make_po_get_domain(self, company_id, values, partner):
('picking_type_id', '=', self.picking_type_id.id),
('company_id', '=', company_id.id),
]
orderpoint = values.get('orderpoint_id')
if orderpoint:

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 2, 2019

Contributor

if values.get('orderpoint_id')

@@ -17,4 +17,7 @@ def _get_lead_days(self, rules):
security_delay = rules.filtered(lambda r: r.action == 'buy').picking_type_id.company_id.po_lead
if security_delay:
lead_days_description += '<tr><td>%s</td><td>+ %d day(s)</td></tr>' % (_('Purchase Security Lead Time'), security_delay)
return lead_days + supplier_delay + security_delay, lead_days_description
days_to_purchase = rules.filtered(lambda r: r.action == 'buy').company_id.days_to_purchase

This comment has been minimized.

Copy link
@Whenrow
@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Dec 2, 2019
if op_product_virtual is None:
continue
if float_compare(op_product_virtual, orderpoint.product_min_qty, precision_rounding=orderpoint.product_uom.rounding) <= 0:
qty = max(orderpoint.product_min_qty, orderpoint.product_max_qty) - op_product_virtual

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 3, 2019

Contributor

max(orderpoint.product_min_qty, orderpoint.product_max_qty) quel usecase on a encore réussi à inventer avec ça ?

except OperationalError:
if use_new_cursor:
cr.rollback()
continue
else:
raise

for orderpoint, error_msg in orderpoints_exceptions:
self.env['stock.rule']._log_next_activity(orderpoint.product_id, error_msg)

This comment has been minimized.

Copy link
@Whenrow

Whenrow Dec 3, 2019

Contributor

move method into product.py


days_to_purchase = fields.Float(string='Days to Purchase', required=True,
help="Days needed to confirm a PO, define when a PO should be validated",
default=0.0)

This comment has been minimized.

Copy link
@sle-odoo

sle-odoo Dec 5, 2019

Contributor
    days_to_purchase = fields.Float(
        string='Days to Purchase', required=True, default=0.0
        help="Days needed to confirm a PO, define when a PO should be validated")
@robodoo robodoo removed the CI 🤖 label Dec 5, 2019
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch 6 times, most recently from a6e658b to 4f467fb Dec 10, 2019
amoyaux added 2 commits Nov 28, 2019
Move the code from stock warehouse to its own file.

[MOV] stock: adapt warehouse and orderpoint files
- lead_days: number of days to add from today in order to define the
procurement request date.
- lead_type purpose is to define if supplier delays should be added
to procurement request date.

Those fields are problematic with the onboarding. The purpose is to
replace them with an automatic computation.

Task 1849912
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch 4 times, most recently from f185022 to 389b46c Dec 11, 2019
@robodoo robodoo added the CI 🤖 label Dec 13, 2019
amoyaux added 7 commits Nov 28, 2019
Orderpoint reference are only set on the first object that is created
from the procurement request. However sometimes we would like to access
it from further object or define another behavior if we come from an
orderpoint.

Now that the we propagate the orderpoint_id, it's important to ignore
po line with an orderpoint AND a chained stock move, else the quantities
will be counted twice by the orderpoint in a 2 steps receipt scenario

Task: 1849912
Currently when a procurement fail it will raise a user error.
Some function as run in stock_rule catch the errors and merge
them in a single error.

Also since commit a2a6b09 procurements
are executed in batch and in some cases, we would like to have more
information about the error. For example in orderpoint we would like to
know which orderpoint is responssible for which error.

It would also be possible to return an object with the details but
procurements pass through a lot of different method that already have
their own return signature and a simple exception is easier to manage.

Task: 1849912
Currently orderpoint run one request at a time. However it's not
efficient since compute are some private methods could be executed
one time in batch instead of record by record.

Instead of a call to run each time a procurement request is ready,
append it to a list and call run with the list of procurements.

Task: 1849912
When the scheduler runs, each orderpoint will check the forecast stock
for an infinite time. As example, if we plan a receipt of 10 products in
4 months and need to deliver 5 products next month, procurement will not
be launched since we have a forecasted quantity of 5.

In order to improve it, the orderpoint will compute the total lead days
from rules, suppliers/production delays, security days,...
Those lead days will be added to today in order to know at which date
the forecast stock should be checked and trigger the replenish document
for today in order to be delivered at the correct date.

Task: 1849912
Create RFQ with an order by date in futur. It will allow to
discuss RFQ before validate them and to be in time for the need.

today            Order by         Sheduled date of receipt
|_______________|___________________|_____________________|
days to purchase      vendor LT           security days

Task: 1849912
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch from 389b46c to 2ce7ca8 Dec 13, 2019
@robodoo robodoo removed the CI 🤖 label Dec 13, 2019
amoyaux added 4 commits Dec 2, 2019
When the user set the schedule date and then the moves. The default date
expected on the move is today. However two inverse function on picking
are trigger. _set_move_without_package and _set_scheduled_date.

In the case where _set_scheduled_date is trigger first it will not write
the date on the stock_move and the stock_move will be created afterward.
In this case the move will have today as date and the picking date will
remains in the future. That could be confusing for the user and
problematic for the forecast report that are focus on the move date.

In order to fix it, set a default_date on move that is equals to the
schedule date on its picking.

It remains an issue that _set_scheduled_date could trigger after
_set_move_without_package and would erase all the manual date from the
user. However it could not be fix without involve existing feature nor
adding a new button.

Task: 1849912
_log_next_activity was on stock.rule and should have been
@api.model. So it should rather be on product template but
it's probably not necessary to have a function for it since
it's only used by orderpoint process.
@amoyaux amoyaux force-pushed the odoo-dev:master-rr-replenish-frequency-arm branch from 2ce7ca8 to b92f944 Dec 13, 2019
@robodoo robodoo added the CI 🤖 label Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.