Files
rma/website_rma/models/ir_model.py
Ernesto Tejeda 1d84cdca60 [ADD] website_sale: new module
This module adds a website form to allows to create an RMA from scratch
2022-08-22 12:06:54 +02:00

24 lines
836 B
Python

# Copyright 2020 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, models
class IrModel(models.Model):
_inherit = 'ir.model'
@api.model
def get_authorized_fields(self, model_name):
"""Hack this method to force some rma fields to be authorized in
creating an object from a web form using the website_form module.
Those fields are readonly in all states except 'draft' state,
but the main method get_authorized_fields interprets them as
readonly always.
"""
res = super().get_authorized_fields(model_name)
if model_name == 'rma':
auth_fields = ['product_uom_qty', 'product_uom', 'partner_id']
res.update(self.env[model_name].fields_get(auth_fields))
return res