From ef860cf6815dceb0a806a08b2118390830ccdae0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 4 Jun 2025 16:57:56 +0700 Subject: purchase pricelist and schema invoice --- fixco_custom/__manifest__.py | 1 + fixco_custom/models/__init__.py | 1 + fixco_custom/models/account_move.py | 4 ++- fixco_custom/models/purchase_pricelist.py | 18 ++++++++++ fixco_custom/models/sale.py | 4 +++ fixco_custom/security/ir.model.access.csv | 3 +- fixco_custom/views/account_move.xml | 7 ++++ fixco_custom/views/purchase_pricelist.xml | 57 +++++++++++++++++++++++++++++++ 8 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 fixco_custom/models/purchase_pricelist.py create mode 100644 fixco_custom/views/purchase_pricelist.xml diff --git a/fixco_custom/__manifest__.py b/fixco_custom/__manifest__.py index 62a199e..4abf544 100755 --- a/fixco_custom/__manifest__.py +++ b/fixco_custom/__manifest__.py @@ -22,6 +22,7 @@ 'views/account_move.xml', 'views/upload_payments.xml', 'views/ir_sequence.xml', + 'views/purchase_pricelist.xml', ], 'demo': [], 'css': [], diff --git a/fixco_custom/models/__init__.py b/fixco_custom/models/__init__.py index a6fc1c9..c362a04 100755 --- a/fixco_custom/models/__init__.py +++ b/fixco_custom/models/__init__.py @@ -8,3 +8,4 @@ from . import barcoding_product from . import sale_order_multi_invoices from . import account_move from . import upload_payments +from . import purchase_pricelist diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index bf7ffc9..3f52319 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -15,4 +15,6 @@ class AccountMove(models.Model): _inherit = 'account.move' invoice_marketplace = fields.Char('Invoice Marketplace') - address = fields.Char('Address') \ No newline at end of file + address = fields.Char('Address') + sale_id = fields.Many2one('sale.order', string='Sale Order') + picking_id = fields.Many2one('stock.picking', string='Picking') \ No newline at end of file diff --git a/fixco_custom/models/purchase_pricelist.py b/fixco_custom/models/purchase_pricelist.py new file mode 100644 index 0000000..2d0a77c --- /dev/null +++ b/fixco_custom/models/purchase_pricelist.py @@ -0,0 +1,18 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import datetime, timedelta +from pytz import timezone + +class PurchasePricelist(models.Model): + _name = 'purchase.pricelist' + _rec_name = 'product_id' + _inherit = ['mail.thread', 'mail.activity.mixin'] + + name = fields.Char(string='Name', compute="_compute_name") + product_id = fields.Many2one('product.product', string="Product", required=True) + vendor_id = fields.Many2one('res.partner', string="Vendor", required=True) + price = fields.Float(string='Price', required=True) + + @api.depends('product_id', 'vendor_id') + def _compute_name(self): + self.name = self.vendor_id.name + ', ' + self.product_id.name \ No newline at end of file diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 6d7a7e6..b36f4b5 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -29,11 +29,15 @@ class SaleOrder(models.Model): if not journal: raise UserError(_('Please define an accounting sales journal for the company %s (%s).') % (self.company_id.name, self.company_id.id)) + done_pickings = self.picking_ids.filtered(lambda p: p.state == 'done').sorted(key='create_date') invoice_vals = { 'ref': self.client_order_ref or '', 'move_type': 'out_invoice', 'narration': self.note, 'invoice_marketplace': self.invoice_mp, + 'address': self.address, + 'sale_id': self.id, + 'picking_id': done_pickings[0] if done_pickings else False, 'currency_id': self.pricelist_id.currency_id.id, 'campaign_id': self.campaign_id.id, 'medium_id': self.medium_id.id, diff --git a/fixco_custom/security/ir.model.access.csv b/fixco_custom/security/ir.model.access.csv index 3556565..a5a3434 100755 --- a/fixco_custom/security/ir.model.access.csv +++ b/fixco_custom/security/ir.model.access.csv @@ -8,4 +8,5 @@ access_barcoding_product_line,access.barcoding.product.line,model_barcoding_prod access_sale_order_multi_invoices,access.sale.order.multi_invoices,model_sale_order_multi_invoices,,1,1,1,1 access_account_move,access.account.move,model_account_move,,1,1,1,1 access_upload_payments,access.upload.payments,model_upload_payments,,1,1,1,1 -access_upload_payments_line,access.upload.payments.line,model_upload_payments_line,,1,1,1,1 \ No newline at end of file +access_upload_payments_line,access.upload.payments.line,model_upload_payments_line,,1,1,1,1 +access_purchase_pricelist,access.purchase.pricelist,model_purchase_pricelist,,1,1,1,1 \ No newline at end of file diff --git a/fixco_custom/views/account_move.xml b/fixco_custom/views/account_move.xml index c7d4cf1..7e24873 100644 --- a/fixco_custom/views/account_move.xml +++ b/fixco_custom/views/account_move.xml @@ -9,6 +9,13 @@ + + + + + + + diff --git a/fixco_custom/views/purchase_pricelist.xml b/fixco_custom/views/purchase_pricelist.xml new file mode 100644 index 0000000..b4e70f6 --- /dev/null +++ b/fixco_custom/views/purchase_pricelist.xml @@ -0,0 +1,57 @@ + + + + purchase.pricelist.tree + purchase.pricelist + + + + + + + + + + + purchase.pricelist.form + purchase.pricelist + +
+ + + + + + + + + +
+ + + +
+
+
+
+ + + Purchase Pricelist + ir.actions.act_window + purchase.pricelist + tree,form + +

+ Add Purchase Pricelist! +

+
+
+ + +
\ No newline at end of file -- cgit v1.2.3