mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-22 07:32:07 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
from . import res_company
|
||||
from . import res_config_settings
|
||||
from . import rma
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2022 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
rma_delivery_strategy = fields.Selection(
|
||||
selection=[
|
||||
("fixed_method", "Fixed method"),
|
||||
("customer_method", "Customer method"),
|
||||
("mixed_method", "Customer method (fallback to fixed)"),
|
||||
],
|
||||
string="RMA delivery method strategy",
|
||||
default="mixed_method",
|
||||
)
|
||||
rma_fixed_delivery_method = fields.Many2one(
|
||||
comodel_name="delivery.carrier",
|
||||
string="Default RMA delivery method",
|
||||
)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2022 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = "res.config.settings"
|
||||
|
||||
rma_delivery_strategy = fields.Selection(
|
||||
related="company_id.rma_delivery_strategy",
|
||||
readonly=False,
|
||||
)
|
||||
rma_fixed_delivery_method = fields.Many2one(
|
||||
related="company_id.rma_fixed_delivery_method",
|
||||
readonly=False,
|
||||
)
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
# Copyright 2022 Tecnativa - David Vidal
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
from odoo import models
|
||||
|
||||
|
||||
class Rma(models.Model):
|
||||
_inherit = "rma"
|
||||
|
||||
def _get_default_carrier_id(self, company, partner):
|
||||
"""Gather the company option for default carrier on RMA returns. We could
|
||||
either:
|
||||
- Get a fixed method
|
||||
- Get the partner's defined method (or his commercial entity one)
|
||||
- Get the partner's and fallback to a fixed one if defined
|
||||
"""
|
||||
strategy = company.rma_delivery_strategy
|
||||
delivery_method = company.rma_fixed_delivery_method
|
||||
partner_method = (
|
||||
partner.property_delivery_carrier_id
|
||||
or partner.commercial_partner_id.property_delivery_carrier_id
|
||||
)
|
||||
if strategy == "customer_method" or (
|
||||
strategy == "mixed_method" and partner_method
|
||||
):
|
||||
delivery_method = partner_method
|
||||
return delivery_method
|
||||
|
||||
def _prepare_returning_picking(self, picking_form, origin=None):
|
||||
res = super()._prepare_returning_picking(picking_form, origin)
|
||||
picking_form.carrier_id = self._get_default_carrier_id(
|
||||
picking_form.company_id, picking_form.partner_id
|
||||
)
|
||||
return res
|
||||
|
||||
def _set_carrier(self, pickings):
|
||||
for picking in pickings:
|
||||
picking.carrier_id = self._get_default_carrier_id(
|
||||
picking.company_id, picking.partner_id
|
||||
)
|
||||
|
||||
def create_replace(self, scheduled_date, warehouse, product, qty, uom):
|
||||
existing_pickings = self.delivery_move_ids.picking_id
|
||||
res = super().create_replace(scheduled_date, warehouse, product, qty, uom)
|
||||
self._set_carrier(self.delivery_move_ids.picking_id - existing_pickings)
|
||||
return res
|
||||
|
||||
def create_return(self, scheduled_date, qty=None, uom=None):
|
||||
existing_pickings = self.delivery_move_ids.picking_id
|
||||
res = super().create_return(scheduled_date, qty=qty, uom=uom)
|
||||
self._set_carrier(self.delivery_move_ids.picking_id - existing_pickings)
|
||||
return res
|
||||
Loading…
Add table
Add a link
Reference in a new issue