print serial_no on invoice if a product has serial_no_tracking
							parent
							
								
									85bfc5dc0c
								
							
						
					
					
						commit
						8dd72576ac
					
				|  | @ -1,7 +1,7 @@ | ||||||
| # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>) | # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>) | ||||||
| # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). | # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). | ||||||
| 
 | 
 | ||||||
| from odoo import api, models | from odoo import api, fields, models | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class AccountInvoice(models.Model): | class AccountInvoice(models.Model): | ||||||
|  | @ -28,3 +28,47 @@ class AccountInvoice(models.Model): | ||||||
|                 if sale_order: |                 if sale_order: | ||||||
|                     category['order_id'] = sale_order |                     category['order_id'] = sale_order | ||||||
|         return res |         return res | ||||||
|  | 
 | ||||||
|  | class AccountInvoiceLine(models.Model): | ||||||
|  |     _inherit = "account.invoice.line" | ||||||
|  | 
 | ||||||
|  |     order_line_ids = fields.Many2many( | ||||||
|  |         comodel_name='sale.order.line', | ||||||
|  |         relation='sale_order_line_invoice_rel', | ||||||
|  |         column1='invoice_line_id', | ||||||
|  |         column2='order_line_id', | ||||||
|  |         string='Order Lines', | ||||||
|  |         readonly=True, | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     prod_lot_ids = fields.Many2many( | ||||||
|  |         comodel_name='stock.production.lot', | ||||||
|  |         compute='_compute_prod_lots', | ||||||
|  |         string="Production Lots", | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     lot_formatted_note = fields.Html( | ||||||
|  |         string='Formatted Note', | ||||||
|  |         compute='_compute_line_lots', | ||||||
|  |     ) | ||||||
|  | 
 | ||||||
|  |     @api.multi | ||||||
|  |     def _compute_prod_lots(self): | ||||||
|  |         for line in self: | ||||||
|  |             if not line.order_line_ids: | ||||||
|  |                 return | ||||||
|  |             line.prod_lot_ids = self.mapped( | ||||||
|  |                 'order_line_ids.move_ids.move_line_ids.lot_id') | ||||||
|  |         print('End') | ||||||
|  | 
 | ||||||
|  |     @api.multi | ||||||
|  |     def _compute_line_lots(self): | ||||||
|  |         for line in self: | ||||||
|  |             if line.prod_lot_ids: | ||||||
|  |                 note = u'<ul>' | ||||||
|  |                 note += u' '.join([ | ||||||
|  |                     u'<li>S/N {0}</li>'.format(lot.name) | ||||||
|  |                     for lot in line.prod_lot_ids | ||||||
|  |                 ]) | ||||||
|  |                 note += u'</ul>' | ||||||
|  |                 line.lot_formatted_note = note | ||||||
|  |  | ||||||
|  | @ -85,6 +85,8 @@ | ||||||
|                 <t t-foreach="o.order_lines_layouted()" t-as="page" name="lines_layouted"> |                 <t t-foreach="o.order_lines_layouted()" t-as="page" name="lines_layouted"> | ||||||
|                     <table class="table table-condensed"> |                     <table class="table table-condensed"> | ||||||
|                         <t t-set="discount_is_set" t-value="field_set_in_lines(o.invoice_line_ids, 'discount')"/> |                         <t t-set="discount_is_set" t-value="field_set_in_lines(o.invoice_line_ids, 'discount')"/> | ||||||
|  |                         <t t-set="has_serial_number" t-value="o.invoice_line_ids.mapped('prod_lot_ids')" | ||||||
|  |                            groups="stock.group_production_lot"/> | ||||||
|                         <thead class="table-header"> |                         <thead class="table-header"> | ||||||
|                             <tr> |                             <tr> | ||||||
|                                 <th class="text-center">Pos.</th> |                                 <th class="text-center">Pos.</th> | ||||||
|  | @ -182,6 +184,12 @@ | ||||||
|                                                 <span t-field="invoice_line.intrastat_id"/> |                                                 <span t-field="invoice_line.intrastat_id"/> | ||||||
|                                                 <br/> |                                                 <br/> | ||||||
|                                             </span> |                                             </span> | ||||||
|  |                                             <span t-if="invoice_line.product_id.tracking=='serial'"> | ||||||
|  |                                                 <strong>Serien Nr.:</strong> | ||||||
|  |                                                 <t t-if="has_serial_number"> | ||||||
|  |                                                     <span t-field="invoice_line.lot_formatted_note" /> | ||||||
|  |                                                 </t> | ||||||
|  |                                             </span> | ||||||
|                                             <span t-field="invoice_line.name"/> |                                             <span t-field="invoice_line.name"/> | ||||||
|                                             <p t-if="invoice_line.lot_id.notes"> |                                             <p t-if="invoice_line.lot_id.notes"> | ||||||
|                                                 <span t-field="invoice_line.lot_id.notes"/> |                                                 <span t-field="invoice_line.lot_id.notes"/> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue