0
votes

I have downloaded an app for Odoo10 that inherits res.partner: https://www.odoo.com/apps/modules/10.0/partner_credit_limit/

After install that app in my Odoo, I see that the field over_credit (res.partner) is overwritten, and changes to True by default. That's OK. The problem is that when I try to overwrite another field (credit_limit, from res_partner) it doesn't changes. Then, I added a new field (x_riesgo_subjetivo), but it appears in the form, but with no Selection possible (it's a Selection field). It's already created on the database as x_riesgo_subjetivo.

The code is:

models/partner.py (declared in the init of models folder)

from odoo import fields, models
class ResPartner(models.Model)
_inherit = 'res.partner'
over_credit = fields.Boolean('Allow Over Credit? modified', default=True)
credit_limit = fields.Float(digits=0, required=True, default=1000.0, help="Help Text")
x_riesgo_subjetivo = fields.Selection([('good', 'Good Debtor'), ('normal', 'Normal Debtor'), ('bad', 'Bad Debtor')], string='Degree of trust you have in this debtor', default='normal', company_dependent=True)

views/partner_view.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="view_category_property_form" model="ir.ui.view">
        <field name="name">partner.over.credit.limit.form.inherit</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="account.view_partner_property_form"/>
        <field name="arch" type="xml">
            <field name="credit" position="after">
                <field name="credit_limit"/>
                <field name="over_credit"/>
                <field name="x_riesgo_subjetivo"/>
            </field>
        </field>
    </record>
</odoo>

Furthermore, when I change the default=True in the over_credit field, to default=False, it doesn't change when I créate a new Partner.

Would you help me to discover what am I doing wrong? I'm inheriting from res.partner, and when I try the app, everything seems to run OK. But when I add my changes, it doesn't Works as I want. Perhaps am I missing some configuration in Odoo?

Thank you.

1

1 Answers

0
votes

On the first place, both a colon (:) is missing and Python-required indentation are missing on your model declaration:

from odoo import fields, models

class ResPartner(models.Model):
  _inherit = 'res.partner'
  over_credit = fields.Boolean('Allow Over Credit? modified', default=True)
  credit_limit = fields.Float(digits=0, required=True, default=1000.0, help="Help Text")
  x_riesgo_subjetivo = fields.Selection([('good', 'Good Debtor'), ('normal', 'Normal Debtor'), ('bad', 'Bad Debtor')], string='Degree of trust you have in this debtor', default='normal', company_dependent=True)

On the other hand, I'm testing your code on v12 and the field credit doesn't exist anymore so I used vat, and it works like a charm.

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <record id="view_category_property_form" model="ir.ui.view">
        <field name="name">partner.over.credit.limit.form.inherit</field>
        <field name="model">res.partner</field>
        <field name="type">form</field>
        <field name="inherit_id" ref="account.view_partner_property_form"/>
        <field name="arch" type="xml">
            <field name="vat" position="after">
                <field name="credit_limit"/>
                <field name="over_credit"/>
                <field name="x_riesgo_subjetivo"/>
            </field>
        </field>
    </record>
</odoo>

I can upload a minimal working module for v12 to github if you need me to.

By the way, do you have files named __init__.py containing

from . import models

and models/__init__.py containing

from . import partner

?

modified res.partner form screenshot