60 lines
2.1 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",
)
2019-12-30 10:21:33 +05:00
name_genitive = fields.Char(string="Name Genitive",)
name_initials = fields.Char(string="Name Initials",)
function_genitive = fields.Char(string="Function Genitive",) # TODO: have no use of this
2019-11-12 16:16:14 +05:00
client_contract_ids = fields.One2many(
2019-12-17 09:53:47 +05:00
"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
2019-12-17 09:53:47 +05:00
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-09 08:32:13 +05:00
phone_whatsapp = fields.Char(
2019-12-30 16:01:44 +05:00
string="WhatsApp", help="If a contact have a WhatsApp number",
)
phone_telegram = fields.Char(
string="Telegram", help="If a contact have a Telegram number or identifier",
)
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
@api.one
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):
self.contract_count = len(self.client_contract_ids)