74 lines
2.2 KiB
Python
Raw Normal View History

2019-11-12 16:16:14 +05:00
from odoo import api, fields, models
class ResPartner(models.Model):
2019-12-17 09:53:47 +05:00
_inherit = "res.partner"
2019-11-12 16:16:14 +05:00
name_write = fields.Char(
string="Name in contracts",
help="This name uses in contracts",
)
name_genitive = fields.Char(
string="Name Genitive",
)
name_initials = fields.Char(
string="Name Initials",
)
function_genitive = fields.Char(
string="Function Genitive",
)
2019-11-12 16:16:14 +05:00
client_contract_ids = fields.One2many(
"res.partner.contract",
"partner_id",
string="Contracts",
2019-11-12 16:16:14 +05:00
)
contract_count = fields.Integer(
2019-12-17 09:53:47 +05:00
compute="_compute_contract_count", string="# of contracts"
2019-11-12 16:16:14 +05:00
)
2019-12-12 20:01:33 +05:00
full_address = fields.Char(
2019-12-17 09:53:47 +05:00
compute="_compute_full_address"
) # Check for res.partner.contact_address in base/res
street_actual = fields.Many2one(
"res.partner",
string="Actual Address",
)
2019-11-12 16:16:14 +05:00
representative_id = fields.Many2one(
2019-12-17 09:53:47 +05:00
"res.partner", string="Representative", help="Person, who represents company"
2019-11-12 16:16:14 +05:00
)
representative_document = fields.Char(
string="Representative acts on the basis of",
help="Parent Case",
)
2019-12-17 09:53:47 +05:00
signature = fields.Binary(string="Client signature")
2020-01-20 13:48:34 +05:00
whatsapp = fields.Char(
string="WhatsApp",
help="If a contact have a WhatsApp number",
2019-12-30 16:01:44 +05:00
)
2020-01-20 13:48:34 +05:00
telegram = fields.Char(
string="Telegram",
help="If a contact have a Telegram number or identifier",
2019-12-30 16:01:44 +05:00
)
2019-11-12 16:16:14 +05:00
2019-12-17 09:53:47 +05:00
@api.depends("street", "street2", "city", "state_id", "zip", "country_id")
2019-12-12 20:01:33 +05:00
def _compute_full_address(self):
for record in self:
2019-12-17 09:53:47 +05:00
data = filter(
None,
map(
lambda s: s and s.strip(),
[
record.zip,
record.street,
record.street2,
record.country_id.name,
record.city,
],
),
)
record.full_address = ", ".join(data)
2019-11-12 16:16:14 +05:00
2019-12-17 09:53:47 +05:00
@api.depends("self.client_contract_ids")
2019-11-12 16:16:14 +05:00
def _compute_contract_count(self):
2021-04-28 18:55:01 +05:00
self.ensure_one()
2019-11-12 16:16:14 +05:00
self.contract_count = len(self.client_contract_ids)