summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-06-24 13:59:07 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-06-24 13:59:07 +0700
commita7139584557cc8c0d881bafc25b4cbbdb1c93ffc (patch)
tree14efe1f3daaa253b558086c62e310acd34d6f22b
parente921762879216dbe8df4e36dfa294ae4ccf293ee (diff)
(andri) ganti compute field menjadi field biasa
-rw-r--r--indoteknik_custom/models/res_partner.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py
index d23ab824..d439c7a8 100644
--- a/indoteknik_custom/models/res_partner.py
+++ b/indoteknik_custom/models/res_partner.py
@@ -164,23 +164,22 @@ class ResPartner(models.Model):
"Set its value to 0.00 to disable "
"this feature", tracking=3)
telegram_id = fields.Char(string="Telegram")
-
avg_aging= fields.Float(string='Average Aging')
- payment_difficulty = fields.Selection([('bermasalah', 'Bermasalah'),('sulit', 'Sulit'),('agak_sulit', 'Agak Sulit'),('normal', 'Normal')], string='Payment Difficulty', tracking=3, compute='_compute_payment_difficulty', inverse='_inverse_payment_difficulty')
+ payment_difficulty = fields.Selection([('bermasalah', 'Bermasalah'),('sulit', 'Sulit'),('agak_sulit', 'Agak Sulit'),('normal', 'Normal')], string='Payment Difficulty', tracking=3)
payment_history_url = fields.Text(string='Payment History URL')
- @api.depends('parent_id.payment_difficulty')
- def _compute_payment_difficulty(self):
- for partner in self:
- if partner.parent_id:
- partner.payment_difficulty = partner.parent_id.payment_difficulty
+ # @api.depends('parent_id.payment_difficulty')
+ # def _compute_payment_difficulty(self):
+ # for partner in self:
+ # if partner.parent_id:
+ # partner.payment_difficulty = partner.parent_id.payment_difficulty
- def _inverse_payment_difficulty(self):
- for partner in self:
- if not partner.parent_id:
- partner.child_ids.write({
- 'payment_difficulty': partner.payment_difficulty
- })
+ # def _inverse_payment_difficulty(self):
+ # for partner in self:
+ # if not partner.parent_id:
+ # partner.child_ids.write({
+ # 'payment_difficulty': partner.payment_difficulty
+ # })
@api.model
def _default_payment_term(self):
@@ -209,6 +208,10 @@ class ResPartner(models.Model):
for rec in self:
if 'latitude' in vals or 'longtitude' in vals:
rec._update_address_from_coords()
+
+ # Sinkronisasi payment_difficulty ke semua anak jika partner ini adalah parent
+ if not rec.parent_id and 'payment_difficulty' in vals:
+ rec.child_ids.write({'payment_difficulty': vals['payment_difficulty']})
#
# # if 'property_payment_term_id' in vals:
# # if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26:
@@ -227,6 +230,8 @@ class ResPartner(models.Model):
for rec in records:
if vals.get('latitude') and vals.get('longtitude'):
rec._update_address_from_coords()
+ if rec.parent_id and not vals.get('payment_difficulty'):
+ rec.payment_difficulty = rec.parent_id.payment_difficulty
return records
@api.constrains('name')