This commit removes the call for tender feature via a purchase.requisition. This feature is to be replaced with the ability to directly compare prices/options of POs/RFQs within a PO to remove extra steps to compare them. The linkage between POs previously provided by a purchase.requistion is replaced by the POs being directly linked to each other. Feature to auto-create call to tenders via a product option is removed and the user is expected to know/be responsible for when they should do a call to tender themselves. All references to old Call to Tenders replaced with Blanket Order, and we remove/rename the menu items since Blanket Order is now the only purchase.requisition.type option (we expect minimal customizated types). Follow-on refactoring to switch purchase.requisition to purchase.blanket.order to come later. Follow-on refactoring to switch purchase.requisition to purchase.blanket.order to come later. Part of Task: 2695116 Upgrade PR: odoo/upgrade#3586 Part-of: odoo/odoo#87656
52 lines
2.3 KiB
Python
52 lines
2.3 KiB
Python
# -*- encoding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models
|
|
|
|
|
|
class StockRule(models.Model):
|
|
_inherit = 'stock.rule'
|
|
|
|
def _prepare_purchase_order(self, company_id, origins, values):
|
|
res = super(StockRule, self)._prepare_purchase_order(company_id, origins, values)
|
|
values = values[0]
|
|
res['partner_ref'] = values['supplier'].purchase_requisition_id.name
|
|
res['requisition_id'] = values['supplier'].purchase_requisition_id.id
|
|
if values['supplier'].purchase_requisition_id.currency_id:
|
|
res['currency_id'] = values['supplier'].purchase_requisition_id.currency_id.id
|
|
return res
|
|
|
|
def _make_po_get_domain(self, company_id, values, partner):
|
|
domain = super(StockRule, self)._make_po_get_domain(company_id, values, partner)
|
|
if 'supplier' in values and values['supplier'].purchase_requisition_id:
|
|
domain += (
|
|
('requisition_id', '=', values['supplier'].purchase_requisition_id.id),
|
|
)
|
|
return domain
|
|
|
|
|
|
class StockMove(models.Model):
|
|
_inherit = 'stock.move'
|
|
|
|
requisition_line_ids = fields.One2many('purchase.requisition.line', 'move_dest_id')
|
|
|
|
def _get_upstream_documents_and_responsibles(self, visited):
|
|
# People without purchase rights should be able to do this operation
|
|
requisition_lines_sudo = self.sudo().requisition_line_ids
|
|
if requisition_lines_sudo:
|
|
return [(requisition_line.requisition_id, requisition_line.requisition_id.user_id, visited) for requisition_line in requisition_lines_sudo if requisition_line.requisition_id.state not in ('done', 'cancel')]
|
|
else:
|
|
return super(StockMove, self)._get_upstream_documents_and_responsibles(visited)
|
|
|
|
|
|
class Orderpoint(models.Model):
|
|
_inherit = "stock.warehouse.orderpoint"
|
|
|
|
def _quantity_in_progress(self):
|
|
res = super(Orderpoint, self)._quantity_in_progress()
|
|
for op in self:
|
|
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 l.move_dest_id):
|
|
res[op.id] += prline.product_uom_id._compute_quantity(prline.product_qty, op.product_uom, round=False)
|
|
return res
|