From 0ecd24dd099295d664c3e80f064e8276395a8f89 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 2 Jan 2024 08:56:20 +0700 Subject: change message validation on purchase pricelist and sale order --- indoteknik_custom/models/purchase_pricelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index b7c3785a..86bb2f54 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -39,8 +39,8 @@ class PurchasePricelist(models.Model): ] domain.append(('id', '!=', price.id)) - massage="Product dan vendor yang anda gunakan sudah ada di purchase pricelist" existing_purchase = self.search(domain, limit=1) + massage="Ada duplikat product dan vendor, berikut data yang anda duplikat : \n" + str(existing_purchase.product_id.name) + " - " + str(existing_purchase.vendor_id.name) + " - " + str(existing_purchase.product_price) if existing_purchase: raise UserError(massage) \ No newline at end of file -- cgit v1.2.3 From 3939395d033d8d10f279bc7dd501bc7fbf1a035e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 22 Jan 2024 15:06:14 +0700 Subject: add column to purchase pricelist --- indoteknik_custom/models/purchase_pricelist.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 86bb2f54..b85df109 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -11,12 +11,14 @@ class PurchasePricelist(models.Model): product_id = fields.Many2one('product.product', string="Product", required=True) vendor_id = fields.Many2one('res.partner', string="Vendor", required=True) product_price = fields.Float(string='Human Price', required=True) - system_price = fields.Float(string='System Price', required=True) + system_price = fields.Float(string='System Price', readonly=True) human_last_update = fields.Datetime(string='Human Update') system_last_update = fields.Datetime(string='System Update') count_trx_po = fields.Integer(string='Count Trx Product') count_trx_po_vendor = fields.Integer(string='Count Trx Vendor') - + taxes_product_id = fields.Many2one('account.tax', string='Taxes Human') + taxes_system_id = fields.Many2one('account.tax', string='Taxes System', readonly=True) + include_price = fields.Float(string='Include Price', readonly=True) @api.depends('product_id', 'vendor_id') def _compute_name(self): self.name = self.vendor_id.name + ', ' + self.product_id.name @@ -30,6 +32,21 @@ class PurchasePricelist(models.Model): else: self.human_last_update = current_time + # @api.constrains('system_last_update','system_price') + # def _contrains_include_price(self): + # taxes = self.taxes_system_id or self.taxes_product_id + # tax_include = taxes.price_include + # price_unit = self.system_price or self.product_price + # if taxes: + # if tax_include: + # price_unit = price_unit + # else: + # price_unit = price_unit + (price_unit * 11 / 100) + # else: + # price_unit = price_unit + (price_unit * 11 / 100) + + # self.include_price = price_unit + @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): for price in self: -- cgit v1.2.3 From e5dbcd62560f4083d413d474b123ed971926a2a0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 22 Jan 2024 16:58:11 +0700 Subject: final fix bug purchase pricelist --- indoteknik_custom/models/purchase_pricelist.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index b85df109..9c149ea9 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -32,20 +32,20 @@ class PurchasePricelist(models.Model): else: self.human_last_update = current_time - # @api.constrains('system_last_update','system_price') - # def _contrains_include_price(self): - # taxes = self.taxes_system_id or self.taxes_product_id - # tax_include = taxes.price_include - # price_unit = self.system_price or self.product_price - # if taxes: - # if tax_include: - # price_unit = price_unit - # else: - # price_unit = price_unit + (price_unit * 11 / 100) - # else: - # price_unit = price_unit + (price_unit * 11 / 100) + @api.constrains('system_last_update','system_price') + def _contrains_include_price(self): + taxes = self.taxes_system_id or self.taxes_product_id + tax_include = taxes.price_include + price_unit = self.system_price or self.product_price + if taxes: + if tax_include: + price_unit = price_unit + else: + price_unit = price_unit + (price_unit * 11 / 100) + else: + price_unit = price_unit + (price_unit * 11 / 100) - # self.include_price = price_unit + self.include_price = price_unit @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): -- cgit v1.2.3 From f7fe2253a8c79ff5172cf74c1f1aa341c9bf4f07 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Jan 2024 10:03:42 +0700 Subject: fix bug purchase pricelist, bug automatic purchase, bug log saleorder eta date --- indoteknik_custom/models/purchase_pricelist.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 9c149ea9..af33abbf 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -32,11 +32,12 @@ class PurchasePricelist(models.Model): else: self.human_last_update = current_time - @api.constrains('system_last_update','system_price') + @api.constrains('system_last_update','system_price','product_price','human_last_update') def _contrains_include_price(self): - taxes = self.taxes_system_id or self.taxes_product_id + price_unit, taxes = self._get_valid_price() + # taxes = self.taxes_system_id or self.taxes_product_id + # price_unit = self.system_price or self.product_price tax_include = taxes.price_include - price_unit = self.system_price or self.product_price if taxes: if tax_include: price_unit = price_unit @@ -47,6 +48,20 @@ class PurchasePricelist(models.Model): self.include_price = price_unit + def _get_valid_price(self): + p_price = 0 + taxes = False + + if self.system_price > 0: + if self.product_price > 0 and self.human_last_update > self.system_last_update: + p_price, taxes = self.product_price, self.taxes_product_id + else: + p_price, taxes = self.system_price, self.taxes_system_id + elif self.product_price > 0: + p_price, taxes = self.product_price, self.taxes_product_id + + return p_price, taxes + @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): for price in self: -- cgit v1.2.3 From 90147ac8a57a110ce19c447095cc956e7861dcf5 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Jan 2024 10:53:29 +0700 Subject: fix constrains purchase price list --- indoteknik_custom/models/purchase_pricelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index af33abbf..10326c83 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -32,7 +32,7 @@ class PurchasePricelist(models.Model): else: self.human_last_update = current_time - @api.constrains('system_last_update','system_price','product_price','human_last_update') + @api.constrains('system_last_update','system_price','product_price','human_last_update','taxes_system_id','taxes_product_id') def _contrains_include_price(self): price_unit, taxes = self._get_valid_price() # taxes = self.taxes_system_id or self.taxes_product_id -- cgit v1.2.3 From cd915ccc6ade5eb6c837597ae5a18298a6902aaf Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Jan 2024 10:54:24 +0700 Subject: change name field --- indoteknik_custom/models/purchase_pricelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 10326c83..98f51d03 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -18,7 +18,7 @@ class PurchasePricelist(models.Model): count_trx_po_vendor = fields.Integer(string='Count Trx Vendor') taxes_product_id = fields.Many2one('account.tax', string='Taxes Human') taxes_system_id = fields.Many2one('account.tax', string='Taxes System', readonly=True) - include_price = fields.Float(string='Include Price', readonly=True) + include_price = fields.Float(string='Final Price', readonly=True) @api.depends('product_id', 'vendor_id') def _compute_name(self): self.name = self.vendor_id.name + ', ' + self.product_id.name -- cgit v1.2.3 From 5c07394e695ee3e92d7dfa55f46bf566afb90a7c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Jan 2024 11:05:12 +0700 Subject: filter domain taxes human --- indoteknik_custom/models/purchase_pricelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 98f51d03..43efb7b5 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -16,7 +16,7 @@ class PurchasePricelist(models.Model): system_last_update = fields.Datetime(string='System Update') count_trx_po = fields.Integer(string='Count Trx Product') count_trx_po_vendor = fields.Integer(string='Count Trx Vendor') - taxes_product_id = fields.Many2one('account.tax', string='Taxes Human') + taxes_product_id = fields.Many2one('account.tax', string='Taxes Human', domain=[('type_tax_use', '=', 'purchase')]) taxes_system_id = fields.Many2one('account.tax', string='Taxes System', readonly=True) include_price = fields.Float(string='Final Price', readonly=True) @api.depends('product_id', 'vendor_id') -- cgit v1.2.3 From 331671549aacb0d8f6b4448a4e788fd530f78654 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Jan 2024 15:32:58 +0700 Subject: fix automatic purchase --- indoteknik_custom/models/purchase_pricelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 43efb7b5..c756c301 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -23,7 +23,7 @@ class PurchasePricelist(models.Model): def _compute_name(self): self.name = self.vendor_id.name + ', ' + self.product_id.name - @api.constrains('product_price','system_price','vendor_id','product_id') + @api.constrains('product_price','system_price','vendor_id','product_id','taxes_system_id','taxes_product_id') def _contrains_product_price(self): current_time = fields.Datetime.now(timezone('Asia/Jakarta')).strftime('%Y-%m-%d %H:%M:%S') update_by = self._context.get('update_by') -- cgit v1.2.3 From 8bb31d4a2f2c3037dad4acf8a8f280f9581b5d34 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 26 Jan 2024 15:12:17 +0700 Subject: fix bug include_price --- indoteknik_custom/models/purchase_pricelist.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index c756c301..805ebc89 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -34,7 +34,11 @@ class PurchasePricelist(models.Model): @api.constrains('system_last_update','system_price','product_price','human_last_update','taxes_system_id','taxes_product_id') def _contrains_include_price(self): + price_unit, taxes = self._get_valid_price() + if price_unit == 0: + self.include_price = 0 + return # taxes = self.taxes_system_id or self.taxes_product_id # price_unit = self.system_price or self.product_price tax_include = taxes.price_include -- cgit v1.2.3 From d6c7fad834f954f892cea0eb9e082db822bc8f2b Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 2 Feb 2024 08:58:09 +0700 Subject: fix error purchase pricelist --- indoteknik_custom/models/purchase_pricelist.py | 27 +++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'indoteknik_custom/models/purchase_pricelist.py') diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index 805ebc89..67b22e4c 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -39,8 +39,7 @@ class PurchasePricelist(models.Model): if price_unit == 0: self.include_price = 0 return - # taxes = self.taxes_system_id or self.taxes_product_id - # price_unit = self.system_price or self.product_price + tax_include = taxes.price_include if taxes: if tax_include: @@ -53,18 +52,20 @@ class PurchasePricelist(models.Model): self.include_price = price_unit def _get_valid_price(self): - p_price = 0 - taxes = False + purchase_price = self + price = 0 + taxes = None + human_last_update = purchase_price.human_last_update or datetime.min + system_last_update = purchase_price.system_last_update or datetime.min - if self.system_price > 0: - if self.product_price > 0 and self.human_last_update > self.system_last_update: - p_price, taxes = self.product_price, self.taxes_product_id - else: - p_price, taxes = self.system_price, self.taxes_system_id - elif self.product_price > 0: - p_price, taxes = self.product_price, self.taxes_product_id - - return p_price, taxes + if system_last_update > human_last_update: + price = purchase_price.system_price + taxes = purchase_price.taxes_system_id + else: + price = purchase_price.product_price + taxes = purchase_price.taxes_product_id + + return price, taxes @api.constrains('vendor_id', 'product_id') def _check_duplicate_purchase_pricelist(self): -- cgit v1.2.3