[FIX] mrp_subcontracting: relax subcontractor location requirement
Previously in https://github.com/odoo/odoo/pull/88644/commits/a57be884ee625ab2d67b65f0ece0b8e9b1620369 we restricted the subcontractor locations (property_stock_subcontractor) to locations with the new setting `is_subcontracting_location=True`. The purpose of this new setting is primilarily to support the mrp_subcontracting dropshipping use case though, therefore we want to keep the previous freedom of allowing users to choose any location as a subcontracting_location. There are some routing and filtering errors/confusion that can occur if a user selects a location that isn't marked as `is_subcontracting_location` (or sets this value to false after already assigning it to a subcontractor), but since this has not been reported as an issue in the past, we expect users to properly configure these fields accordingly. Part of general bugfix task: 2985735 closes odoo/odoo#110200 X-original-commit: d86df2b9cef742b6cadd294f57a855634768d039 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com> Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -9,7 +9,6 @@ class ResPartner(models.Model):
|
||||
|
||||
property_stock_subcontractor = fields.Many2one(
|
||||
'stock.location', string="Subcontractor Location", company_dependent=True,
|
||||
domain="[('is_subcontracting_location', '=', True)]",
|
||||
help="The stock location used as source and destination when sending\
|
||||
goods to this contact during a subcontracting process.")
|
||||
is_subcontractor = fields.Boolean(
|
||||
|
||||
@@ -23,12 +23,6 @@ class StockLocation(models.Model):
|
||||
if location.is_subcontracting_location and (location.usage != 'internal' or location.warehouse_id):
|
||||
raise ValidationError(_("In order to manage stock accurately, subcontracting locations must be type Internal, linked to the appropriate company and not specific to a warehouse."))
|
||||
|
||||
@api.constrains('is_subcontracting_location')
|
||||
def _check_is_subcontracting_location(self):
|
||||
for location in self:
|
||||
if not location.is_subcontracting_location and location.subcontractor_ids:
|
||||
raise ValidationError(_("You cannot change the subcontracting location as it is still linked to a subcontractor partner"))
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
res = super().create(vals_list)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="inherit_id" ref="stock.view_partner_stock_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='property_stock_supplier']" position="after">
|
||||
<field name="property_stock_subcontractor" context="{'default_is_subcontracting_location': True}"/>
|
||||
<field name="property_stock_subcontractor"/>
|
||||
<separator/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<field name="inherit_id" ref="stock.view_location_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='return_location']" position='after'>
|
||||
<field name="is_subcontracting_location" groups="base.group_no_one" attrs="{'invisible': [('usage', '!=', 'internal')]}" readonly="context.get('default_is_subcontracting_location', False)"/>
|
||||
<field name="is_subcontracting_location" groups="base.group_no_one" attrs="{'invisible': [('usage', '!=', 'internal')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user