diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-04 13:40:22 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-06-04 13:40:22 +0700 |
| commit | dca58449623e0fd25f2dc301747982da6a5ea940 (patch) | |
| tree | 3a090311c4e9892384acee114fad9ad80c1bb3f5 | |
| parent | 3307dcbdb37285bcd43a719a0ecbc1453e4af9df (diff) | |
add new field on so and invoice
| -rw-r--r-- | fixco_custom/models/account_move.py | 3 | ||||
| -rwxr-xr-x | fixco_custom/models/detail_order.py | 24 | ||||
| -rwxr-xr-x | fixco_custom/models/sale.py | 4 | ||||
| -rwxr-xr-x | fixco_custom/models/stock_picking.py | 2 | ||||
| -rwxr-xr-x | fixco_custom/views/sale_order.xml | 4 |
5 files changed, 29 insertions, 8 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index 73eb851..bf7ffc9 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -14,4 +14,5 @@ _logger = logging.getLogger(__name__) class AccountMove(models.Model): _inherit = 'account.move' - invoice_marketplace = fields.Char('Invoice Marketplace')
\ No newline at end of file + invoice_marketplace = fields.Char('Invoice Marketplace') + address = fields.Char('Address')
\ No newline at end of file diff --git a/fixco_custom/models/detail_order.py b/fixco_custom/models/detail_order.py index 9cbc446..bac1ff5 100755 --- a/fixco_custom/models/detail_order.py +++ b/fixco_custom/models/detail_order.py @@ -114,7 +114,7 @@ class DetailOrder(models.Model): print_info = json_data.get('data', {})[0].get('printInfo', {}).get('labelPrintStatus') if not order_id: raise UserError(_("Order ID not found in JSON data")) - return order_id, order_status, print_info + return order_id, order_status, print_info, json_data raise UserError(_("No JSON data available")) except json.JSONDecodeError: raise UserError(_("Invalid JSON format in detail_order field")) @@ -160,6 +160,7 @@ class DetailOrder(models.Model): def prepare_data_so_line(self, json_data): order_lines = [] items = json_data.get('data', [{}])[0].get('items', []) + product_not_found = False for item in items: product = self.env['product.product'].search( @@ -173,18 +174,19 @@ class DetailOrder(models.Model): 'product_uom_qty': item.get('quantity'), 'price_unit': item.get('actualPrice'), } - + if not product: line_data['name'] = f"{item.get('masterSku')} ({item.get('productName')})" + product_not_found = True order_lines.append((0, 0, line_data)) - return order_lines + return order_lines, product_not_found def execute_queue_detail(self): try: json_data = json.loads(self.detail_order) data = self.prepare_data_so(json_data) - order_lines = self.prepare_data_so_line(json_data) + order_lines, product_not_found = self.prepare_data_so_line(json_data) order_id, order_status, print_info = self.get_order_id_detail() # First check if a sale order with this reference already exists @@ -204,11 +206,16 @@ class DetailOrder(models.Model): self.sale_id = sale_order.id sale_order.order_reference = order_id - sale_order.action_confirm() + sale_order.address = json_data.get('data', [{}])[0].get('shippingAddressInfo', []).get('fullAddress', []) + sale_order.note_by_buyer = json_data.get('data', [{}])[0].get('extraInfo', []).get('noteByBuyer', []) + if not product_not_found: + sale_order.action_confirm() self.picking_id = sale_order.picking_ids[0].id self.picking_id.order_reference = order_id self.picking_id.invoice_mp = sale_order.invoice_mp + self.picking_id.address = json_data.get('data', [{}])[0].get('shippingAddressInfo', []).get('fullAddress', []) + self.picking_id.note_by_buyer = json_data.get('data', [{}])[0].get('extraInfo', []).get('noteByBuyer', []) self.execute_status = 'so_confirm' else: @@ -218,11 +225,16 @@ class DetailOrder(models.Model): self.sale_id = sale_order.id sale_order.order_reference = order_id - sale_order.action_confirm() + sale_order.address = json_data.get('data', [{}])[0].get('shippingAddressInfo', []).get('fullAddress', []) + sale_order.note_by_buyer = json_data.get('data', [{}])[0].get('extraInfo', []).get('noteByBuyer', []) + if not product_not_found: + sale_order.action_confirm() self.picking_id = sale_order.picking_ids[0].id self.picking_id.order_reference = order_id self.picking_id.invoice_mp = sale_order.invoice_mp + self.picking_id.address = json_data.get('data', [{}])[0].get('shippingAddressInfo', []).get('fullAddress', []) + self.picking_id.note_by_buyer = json_data.get('data', [{}])[0].get('extraInfo', []).get('noteByBuyer', []) self.execute_status = 'so_confirm' diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 8269fce..6d7a7e6 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -7,7 +7,9 @@ class SaleOrder(models.Model): carrier = fields.Char(string='Shipping Method') invoice_mp = fields.Char(string='Invoice Marketplace') - order_reference = fields.Char(string='Order Reference') + order_reference = fields.Char(string='Order Reference') + address = fields.Char('Address') + note_by_buyer = fields.Char('Note By Buyer') # def open_form_multi_create_invoices(self): # action = self.env['ir.actions.act_window']._for_xml_id('fixco_custom.action_sale_order_multi_invoices') diff --git a/fixco_custom/models/stock_picking.py b/fixco_custom/models/stock_picking.py index 86810d1..55b6d7e 100755 --- a/fixco_custom/models/stock_picking.py +++ b/fixco_custom/models/stock_picking.py @@ -34,6 +34,8 @@ class StockPicking(models.Model): invoice_number = fields.Char('Invoice Number') pdf_label_url = fields.Char('PDF Label URL') invoice_mp = fields.Char(string='Invoice Marketplace') + address = fields.Char('Address') + note_by_buyer = fields.Char('Note By Buyer') def label_ginee(self): try: diff --git a/fixco_custom/views/sale_order.xml b/fixco_custom/views/sale_order.xml index ed6e12b..2b2b000 100755 --- a/fixco_custom/views/sale_order.xml +++ b/fixco_custom/views/sale_order.xml @@ -9,9 +9,13 @@ <field name="tag_ids" position="after"> <field name="carrier"/> </field> + <field name="partner_id" position="after"> + <field name="address"/> + </field> <field name="client_order_ref" position="after"> <field name="order_reference"/> <field name="invoice_mp" readonly="1"/> + <field name="note_by_buyer" readonly="1"/> </field> </field> </record> |
