Fall 5404, 5403, 5401
							parent
							
								
									a46f55e381
								
							
						
					
					
						commit
						998b1cd90a
					
				|  | @ -18,13 +18,17 @@ | |||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| from odoo import api, fields, models | ||||
| from odoo import api, fields, models, _ | ||||
| from odoo.exceptions import UserError | ||||
| 
 | ||||
| 
 | ||||
| class AccountInvoiceLine(models.Model): | ||||
|     _inherit = 'account.invoice.line' | ||||
| 
 | ||||
|     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code') | ||||
|     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code', | ||||
|                                    compute="_compute_intrastat_id", inverse='_set_intrastat_id') | ||||
|     lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') | ||||
|     weight = fields.Float(string='Gewicht', compute='_compute_weight') | ||||
| 
 | ||||
|     @api.model | ||||
|     def create(self, vals): | ||||
|  | @ -32,6 +36,31 @@ class AccountInvoiceLine(models.Model): | |||
|             vals.update(intrastat_id=self.env['product.template'].browse(vals['product_id']).intrastat_id.id) | ||||
|         return super(AccountInvoiceLine, self).create(vals) | ||||
| 
 | ||||
|     @api.multi | ||||
|     def action_show_lot(self): | ||||
|         self.ensure_one() | ||||
|         action = self.env.ref('stock.action_production_lot_form').read()[0] | ||||
|         action['res_id'] = self.lot_id.id | ||||
|         action['view_mode'] = 'form' | ||||
|         action['views'] = [(False, 'form')] | ||||
| 
 | ||||
|         return action | ||||
| 
 | ||||
|     def _compute_weight(self): | ||||
|         for record in self: | ||||
|             record.weight = record.lot_id.weight or record.product_id.weight | ||||
| 
 | ||||
|     def _compute_intrastat_id(self): | ||||
|         for record in self: | ||||
|             record.intrastat_id = record.lot_id.intrastat_id.id or record.product_id.intrastat_id.id | ||||
| 
 | ||||
|     def _set_intrastat_id(self): | ||||
|         for record in self: | ||||
|             if record.lot_id: | ||||
|                 record.lot_id.intrastat_id = record.intrastat_id.id | ||||
|             else: | ||||
|                 raise UserError(_('Der Intrastrat Code kann nur gesetzt werden wenn ein Lot angegeben wurde.')) | ||||
| 
 | ||||
| 
 | ||||
| class AccountPaymentTerm(models.Model): | ||||
|     _inherit = 'account.payment.term' | ||||
|  | @ -51,7 +80,7 @@ class AccountInvoice(models.Model): | |||
|         for record in self: | ||||
|             _sum = 0 | ||||
|             for line in record.invoice_line_ids: | ||||
|                 _sum += line.product_id.weight * line.quantity | ||||
|                 _sum += line.weight * line.quantity | ||||
|             record.weight_total = _sum | ||||
| 
 | ||||
|     @api.multi | ||||
|  |  | |||
|  | @ -56,7 +56,7 @@ class SaleOrder(models.Model): | |||
|         for record in self: | ||||
|             _sum = 0 | ||||
|             for line in record.order_line: | ||||
|                 _sum += (line.lot_id.weight or line.product_id.weight) * line.product_uom_qty | ||||
|                 _sum += line.weight * line.product_uom_qty | ||||
|             record.weight_total = _sum | ||||
| 
 | ||||
|     @api.multi | ||||
|  | @ -242,7 +242,8 @@ class SaleOrder(models.Model): | |||
|     @api.model | ||||
|     def _get_specified_fields(self): | ||||
|         return ['origin', 'client_order_ref', 'note', 'date_order', 'assembled', 'line_id', 'partner_id', | ||||
|                 'fiscal_position_id', 'user_id', 'payment_term_id', 'partner_delivery_id', 'partner_invoice_id', 'assembly_state'] | ||||
|                 'fiscal_position_id', 'user_id', 'payment_term_id', 'partner_delivery_id', 'partner_invoice_id', | ||||
|                 'assembly_state'] | ||||
| 
 | ||||
|     @api.multi | ||||
|     def write(self, vals): | ||||
|  | @ -330,6 +331,9 @@ class SaleOrderLine(models.Model): | |||
|     lot_id = fields.Many2one(comodel_name='stock.production.lot', string='Lot') | ||||
|     from_designbox = fields.Boolean(string='Import von Designbox', readonly=True) | ||||
|     product_id = fields.Many2one(domain=[('sale_ok', '=', True), ('can_be_sold_unconfigured', '=', True)]) | ||||
|     weight = fields.Float(string='Gewicht', compute='_compute_weight') | ||||
|     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Code', | ||||
|                                    compute="_compute_intrastat_id") | ||||
| 
 | ||||
|     @api.multi | ||||
|     def write(self, vals): | ||||
|  | @ -349,3 +353,31 @@ class SaleOrderLine(models.Model): | |||
|                 raise ValidationError( | ||||
|                     _("Produkt \'%s\' kann nicht zugeordnet werden" % vals['product_id'])) | ||||
|         return vals | ||||
| 
 | ||||
|     @api.multi | ||||
|     def action_show_lot(self): | ||||
|         self.ensure_one() | ||||
|         action = self.env.ref('stock.action_production_lot_form').read()[0] | ||||
|         action['res_id'] = self.lot_id.id | ||||
|         action['view_mode'] = 'form' | ||||
|         action['views'] = [(False, 'form')] | ||||
| 
 | ||||
|         return action | ||||
| 
 | ||||
|     @api.multi | ||||
|     def _compute_weight(self): | ||||
|         for record in self: | ||||
|             record.weight = record.lot_id.weight or record.product_id.weight | ||||
| 
 | ||||
|     @api.multi | ||||
|     def _compute_intrastat_id(self): | ||||
|         for record in self: | ||||
|             record.intrastat_id = record.lot_id.intrastat_id.id or record.product_id.intrastat_id.id | ||||
| 
 | ||||
|     @api.multi | ||||
|     def _prepare_invoice_line(self, qty): | ||||
|         self.ensure_one() | ||||
|         res = super(SaleOrderLine, self)._prepare_invoice_line(qty) | ||||
| 
 | ||||
|         res['lot_id'] = self.lot_id.id | ||||
|         return res | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ class StockProductionLot(models.Model): | |||
| 
 | ||||
|     notes = fields.Text() | ||||
|     weight = fields.Float(string='Gewicht') | ||||
|     intrastat_id = fields.Many2one(comodel_name='report.intrastat.code', string='Intrastat Nummer (Code)') | ||||
|     image = fields.Binary("Produktbild", attachment=True, | ||||
|                           help="Wenn vorhanden, wird dieses Bild in den Angeboten/Aufträgen angedruckt") | ||||
|     image_medium = fields.Binary("Produktbild (resized)", attachment=True, | ||||
|  |  | |||
|  | @ -9,6 +9,15 @@ | |||
|             <xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='name']" position="after"> | ||||
|                 <field name="intrastat_id"/> | ||||
|             </xpath> | ||||
| 
 | ||||
|             <xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='product_id']" position="after"> | ||||
|                 <field name="lot_id" options="{'no_open': True}"/> | ||||
|                 <button name="action_show_lot" string="Lot" type="object" icon="fa-list" | ||||
|                         attrs="{'invisible': [('lot_id', '=', False)]}" options='{"warn": true}'/> | ||||
|             </xpath> | ||||
|             <xpath expr="//field[@name='invoice_line_ids']/kanban//field[@name='product_id']" position="after"> | ||||
|                 <field name="lot_id"/> | ||||
|             </xpath> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|  | @ -24,5 +33,4 @@ | |||
|     </record> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| </odoo> | ||||
|  |  | |||
|  | @ -26,7 +26,8 @@ | |||
|                 <field name="from_designbox"/> | ||||
|             </xpath> | ||||
|             <xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after"> | ||||
|                 <field name="lot_id"/> | ||||
|                 <field name="lot_id" options="{'no_open': True}"/> | ||||
|                 <button name="action_show_lot" string="Lot" type="object" icon="fa-list" attrs="{'invisible': [('lot_id', '=', False)]}" options='{"warn": true}'/> | ||||
|                 <field name="from_designbox"/> | ||||
|             </xpath> | ||||
|             <xpath expr="//field[@name='order_line']/kanban//field[@name='product_id']" position="after"> | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ | |||
|         <field name="arch" type="xml"> | ||||
|             <field name="ref" position="after"> | ||||
|                 <field name="weight"/> | ||||
|                 <field name="intrastat_id"/> | ||||
|                 <field name="notes"/> | ||||
|             </field> | ||||
|             <div class="oe_title" position="before"> | ||||
|  | @ -16,4 +17,8 @@ | |||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="stock.view_production_lot_form"  model="ir.ui.view"> | ||||
|         <field name="priority">0</field> | ||||
|     </record> | ||||
| 
 | ||||
| </odoo> | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| 
 | ||||
| from odoo import api, models | ||||
| from odoo import api, models, _ | ||||
| from odoo.exceptions import ValidationError | ||||
| 
 | ||||
| 
 | ||||
| class AccountInvoice(models.AbstractModel): | ||||
|  | @ -21,3 +22,26 @@ class AccountInvoice(models.AbstractModel): | |||
|             'formatLang': self._formatLang, | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
| class AccountInvoiceWithIntrastat(models.AbstractModel): | ||||
|     _name = 'report.dp_reports_account.report_invoice_with_intrastat' | ||||
|     _inherit = 'report.abstract_report' | ||||
|     _template = 'dp_reports_account.report_invoice_with_intrastat' | ||||
| 
 | ||||
|     @api.model | ||||
|     def get_report_values(self, docids, data=None): | ||||
|         model = 'account.invoice' | ||||
|         docs = self.env[model].browse(docids) | ||||
|         for doc in docs: | ||||
|             for line in doc.invoice_line_ids: | ||||
|                 if not line.intrastat_id: | ||||
|                     raise ValidationError(_('Es muss bei allen Produkten/Lots eine Zolltarifnummer hinterlegt sein!')) | ||||
|         return { | ||||
|             'doc_ids': docids, | ||||
|             'doc_model': model, | ||||
|             'docs': docs, | ||||
|             'data': data, | ||||
|             'field_set_in_lines': self._field_set_in_lines, | ||||
|             'formatLang': self._formatLang, | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -125,7 +125,7 @@ | |||
|                                             <span t-field="invoice_line.quantity"/> | ||||
|                                         </td> | ||||
|                                         <td class="text-right"> | ||||
|                                             <span t-field="invoice_line.product_id.weight"/> | ||||
|                                             <span t-field="invoice_line.weight"/> | ||||
|                                             kg | ||||
|                                         </td> | ||||
|                                         <td class="text-right"> | ||||
|  | @ -137,11 +137,11 @@ | |||
|                                                 </strong> | ||||
|                                                 <br/> | ||||
|                                             </t> | ||||
|                                             <span> | ||||
|                                             <span t-if="with_intrastat"> | ||||
|                                                 <strong>Zolltarif Nr.:</strong> | ||||
|                                                 <span t-field="invoice_line.product_id.intrastat_id"/> | ||||
|                                             </span> | ||||
|                                                 <span t-field="invoice_line.intrastat_id"/> | ||||
|                                                 <br/> | ||||
|                                             </span> | ||||
|                                             <span t-field="invoice_line.name"/> | ||||
|                                         </td> | ||||
|                                         <td rowspan="2" class="text-right"> | ||||
|  | @ -238,6 +238,15 @@ | |||
|         </t> | ||||
|     </template> | ||||
| 
 | ||||
|     <template id="report_invoice_with_intrastat"> | ||||
|         <t t-call="web.html_container"> | ||||
|             <t t-set="with_intrastat" t-value="True"/> | ||||
|             <t t-foreach="docs" t-as="o"> | ||||
|                 <t t-call="dp_reports_account.report_invoice_document" t-lang="o.partner_id.lang"/> | ||||
|             </t> | ||||
|         </t> | ||||
|     </template> | ||||
| 
 | ||||
|     <record id="account.account_invoices" model="ir.actions.report"> | ||||
|         <field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/> | ||||
|         <field name="binding_model_id" eval="False"/> | ||||
|  | @ -248,8 +257,20 @@ | |||
|         <field name="binding_model_id" eval="False"/> | ||||
|     </record> | ||||
| 
 | ||||
|     <report | ||||
|             id="account_invoices_with_intrastat" | ||||
|             model="account.invoice" | ||||
|             string="Rechnung mit Zolltarifnummer" | ||||
|             report_type="qweb-pdf" | ||||
|             name="dp_reports_account.report_invoice_with_intrastat" | ||||
|             file="dp_reports_account.report_invoice_with_intrastat" | ||||
|             attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')" | ||||
|             print_report_name="(object._get_printed_report_name())" | ||||
|             paperformat="dp_reports.paperformat_a4_european" | ||||
|         /> | ||||
| 
 | ||||
|     <record id="account.account_invoices_without_payment" model="ir.actions.report"> | ||||
|         <field name="name">Rechnungen</field> | ||||
|         <field name="name">Rechnung ohne Zolltarifnummer</field> | ||||
|         <field name="paperformat_id" ref="dp_reports.paperformat_a4_european"/> | ||||
|     </record> | ||||
| </odoo> | ||||
|  |  | |||
|  | @ -98,11 +98,8 @@ | |||
|                                 <td class="text-left"> | ||||
|                                     <span t-field="order_line.product_uom_qty"/> | ||||
|                                 </td> | ||||
|                                 <td t-if="not order_line.lot_id.weight" class="text-right"> | ||||
|                                     <span t-field="order_line.product_id.weight"/> kg | ||||
|                                 </td> | ||||
|                                 <td t-if="order_line.lot_id.weight" class="text-right"> | ||||
|                                     <span t-field="order_line.lot_id.weight"/> kg | ||||
|                                 <td class="text-right"> | ||||
|                                     <span t-field="order_line.weight"/> kg | ||||
|                                 </td> | ||||
|                                 <td class="text-right"> | ||||
|                                 </td> | ||||
|  | @ -115,7 +112,7 @@ | |||
|                                     </t> | ||||
|                                     <span> | ||||
|                                         <strong>Zolltarif Nr.:</strong> | ||||
|                                         <span t-field="order_line.product_id.intrastat_id"/> | ||||
|                                         <span t-field="order_line.intrastat_id"/> | ||||
|                                     </span> | ||||
|                                     <br/> | ||||
|                                     <span t-field="order_line.name"/> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue