new: 'Indiviual Discount`' insted of 'Dealer Discount'; Additional Filter for Invoices 'Referenzbeleg'
							parent
							
								
									68107851ee
								
							
						
					
					
						commit
						2246c6caa9
					
				|  | @ -80,6 +80,8 @@ class AccountInvoice(models.Model): | |||
|     num_items = fields.Integer(string='Anzahl der Artikel', compute='_compute_num_items') | ||||
|     weight_total = fields.Float(string='Gesamtgewicht', compute='_compute_weight_total') | ||||
| 
 | ||||
|     layout_category_id = fields.Many2one('sale.layout_category', related='invoice_line_ids.layout_category_id', string='Section') | ||||
| 
 | ||||
|     @api.multi | ||||
|     def action_invoice_open(self): | ||||
|         to_open_invoices = self.filtered(lambda inv: inv.state != 'open') | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ | |||
|                 <button name="%(action_wizard_confirm_null_invoice)d" type="action" string="Validate" states="draft" class="oe_highlight o_invoice_validate" groups="account.group_account_invoice"/> | ||||
|             </xpath> | ||||
| --> | ||||
|             <field name="layout_category_id"/> | ||||
|             <xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='name']" position="after"> | ||||
|                 <field name="intrastat_id" options="{'no_quick_create':True}"/> | ||||
|             </xpath> | ||||
|  | @ -44,11 +45,25 @@ | |||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="account_invoice_tree_section" model="ir.ui.view"> | ||||
|         <field name="name">account.invoice.tree_section</field> | ||||
|         <field name="model">account.invoice</field> | ||||
|         <field name="inherit_id" ref="account.invoice_tree"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <field name="number" position="after"> | ||||
|                 <field name="layout_category_id"/> | ||||
|             </field> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="view_account_invoice_filter_active" model="ir.ui.view"> | ||||
|         <field name="name">account.invoice.select</field> | ||||
|         <field name="model">account.invoice</field> | ||||
|         <field name="inherit_id" ref="account.view_account_invoice_filter"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <field name="journal_id" position="after"> | ||||
|                 <field name="layout_category_id" string="Referenzbeleg"/> | ||||
|             </field> | ||||
|             <xpath expr="//filter[@name='late']" position="after"> | ||||
|                  <filter name="active" string="Nicht abgebrochen" domain="[('state', '!=', 'cancel')]"/> | ||||
|             </xpath> | ||||
|  |  | |||
|  | @ -7,9 +7,10 @@ from lxml import html | |||
| class Invoice(models.Model): | ||||
|     _inherit = "account.invoice" | ||||
| 
 | ||||
|     dealer_discount = fields.Boolean("Add Dealer Discount", readonly=True, states={'draft': [('readonly', False)]},) | ||||
|     dealer_discount = fields.Boolean("Add Individual Discount", readonly=True, states={'draft': [('readonly', False)]},) | ||||
|     dealer_discount_type = fields.Selection([('fixed','Fixed'),('percentage','Percentage')], | ||||
|         "Discount Type", readonly=True, states={'draft': [('readonly', False)]}, default='fixed') | ||||
|         "Discount Type", readonly=True, states={'draft': [('readonly', False)]}, default='percentage') | ||||
|     dealer_discount_product = fields.Many2one('product.product', string='Rabatt-Artikel', domain=[('categ_id.name', '=', 'Discount')]) | ||||
|     dealer_discount_amount = fields.Float("Discount Amount", readonly=True, states={'draft': [('readonly', False)]},) | ||||
|     dealer_discount_percentage = fields.Float("Discount Percentage", readonly=True, states={'draft': [('readonly', False)]},) | ||||
| 
 | ||||
|  | @ -18,16 +19,24 @@ class Invoice(models.Model): | |||
|         if self.env.user.company_id.invoice_dealer_discount_product_id: | ||||
|             self.env['account.invoice.line'].search([('invoice_id', 'in', self.ids), ('product_id', '=', self.env.user.company_id.invoice_dealer_discount_product_id.id)]).unlink() | ||||
| 
 | ||||
|     @api.multi | ||||
|     def unset_dealer_discount(self): | ||||
|         discount_products_ids = self.env['product.product'].search([('categ_id', '=', 'Discount')]).ids | ||||
|         self.env['account.invoice.line'].search([('invoice_id', 'in', self.ids), ('product_id', 'in', discount_products_ids)]).unlink() | ||||
| 
 | ||||
|     @api.multi | ||||
|     def create_dealer_discount(self): | ||||
|         InvoiceLine = self.env['account.invoice.line'] | ||||
| 
 | ||||
|         discount_product_id = self.env.user.company_id.invoice_dealer_discount_product_id | ||||
|         if not discount_product_id: | ||||
|             raise UserError(_('Please set Invoice Dealer Discount product in General Settings first.')) | ||||
|         if self.dealer_discount_product: | ||||
|             discount_product_id = self.dealer_discount_product | ||||
|         else: | ||||
|         #     discount_product_id = self.env.user.company_id.invoice_dealer_discount_product_id | ||||
|         # if not discount_product_id: | ||||
|             raise UserError(_('Please select Discount product first.')) | ||||
| 
 | ||||
|         # Remove Discount line first | ||||
|         self._dealer_discount_unset() | ||||
| #        self._dealer_discount_unset() | ||||
| 
 | ||||
|         account_id = discount_product_id.property_account_income_id.id | ||||
|         if not account_id: | ||||
|  | @ -94,4 +103,6 @@ class Invoice(models.Model): | |||
| 
 | ||||
|         super()._onchange_invoice_line_ids() | ||||
| 
 | ||||
|         self.dealer_discount_product = '' | ||||
| 
 | ||||
|         return True | ||||
|  |  | |||
|  | @ -7,27 +7,39 @@ from lxml import html | |||
| class SaleOrder(models.Model): | ||||
|     _inherit = "sale.order" | ||||
| 
 | ||||
|     dealer_discount = fields.Boolean("Add Dealer Discount", readonly=True, states={'draft': [('readonly', False),],'sent': [('readonly', False)]},) | ||||
|     dealer_discount = fields.Boolean("Add Discount", readonly=True, states={'draft': [('readonly', False),],'sent': [('readonly', False)]},) | ||||
|     dealer_discount_type = fields.Selection([('fixed','Fixed'),('percentage','Percentage')], | ||||
|         "Discount Type", readonly=True, states={'draft': [('readonly', False)],'sent': [('readonly', False)]}, default='percentage') | ||||
|     dealer_discount_amount = fields.Float("Discount Amount", readonly=True, states={'draft': [('readonly', False)],'sent': [('readonly', False)]},) | ||||
|     dealer_discount_percentage = fields.Float("Discount Percentage", readonly=True, states={'draft': [('readonly', False)],'sent': [('readonly', False)]},) | ||||
|     dealer_discount_product = fields.Many2one('product.product', string='Rabatt-Artikel', domain=[('categ_id.name', '=', 'Discount')]) | ||||
|     dealer_discount_amount = fields.Float("Discount Amount", readonly=True, states={'draft': [('readonly', False)],'sent': [('readonly', False)]}, | ||||
|                                           size = 10,) | ||||
|     dealer_discount_percentage = fields.Float("Discount Percentage", readonly=True, | ||||
|                                               states={'draft': [('readonly', False)],'sent': [('readonly', False)]}, | ||||
|                                               size = 5,) | ||||
| 
 | ||||
|     @api.multi | ||||
|     def _dealer_discount_unset(self): | ||||
|         if self.env.user.company_id.sale_dealer_discount_product_id: | ||||
|             self.env['sale.order.line'].search([('order_id', 'in', self.ids), ('product_id', '=', self.env.user.company_id.sale_dealer_discount_product_id.id)]).unlink() | ||||
| 
 | ||||
|     @api.multi | ||||
|     def unset_dealer_discount(self): | ||||
|         discount_products_ids = self.env['product.product'].search([('categ_id', '=', 'Discount')]).ids | ||||
|         self.env['sale.order.line'].search([('order_id', 'in', self.ids), ('product_id', 'in', discount_products_ids)]).unlink() | ||||
| 
 | ||||
|     @api.multi | ||||
|     def create_dealer_discount(self): | ||||
|         Line = self.env['sale.order.line'] | ||||
| 
 | ||||
|         discount_product_id = self.env.user.company_id.sale_dealer_discount_product_id | ||||
|         if not discount_product_id: | ||||
|             raise UserError(_('Please set Sale Dealer Discount product in General Settings first.')) | ||||
|         if self.dealer_discount_product: | ||||
|             discount_product_id = self.dealer_discount_product | ||||
|         else: | ||||
|         #     discount_product_id = self.env.user.company_id.sale_dealer_discount_product_id | ||||
|         # if not discount_product_id: | ||||
|             raise UserError(_('Please select Discount product first.')) | ||||
| 
 | ||||
|         # Remove Discount line first | ||||
|         self._dealer_discount_unset() | ||||
| #        self._dealer_discount_unset() | ||||
| 
 | ||||
|         for order in self: | ||||
|             amount = 0 | ||||
|  | @ -70,4 +82,6 @@ class SaleOrder(models.Model): | |||
|                     'sequence': 99999, | ||||
|                 }) | ||||
| 
 | ||||
|             self.dealer_discount_product = '' | ||||
| 
 | ||||
|         return True | ||||
|  |  | |||
|  | @ -13,10 +13,16 @@ | |||
|                     <div name='dealer_discount'> | ||||
|                         <div> | ||||
|                             <field name='dealer_discount' class="oe_inline" nolabel="1" attrs="{'invisible': [('state','!=', 'draft')]}"/> | ||||
|                             <field name='dealer_discount_product' class="oe_inline" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False),'&', ('state','!=', 'draft')]}"/> | ||||
|                             <field name='dealer_discount_type' class="oe_inline" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False), ('state','!=', 'draft')], 'required':[('dealer_discount','!=', False)]}"/> | ||||
|                             <field name='dealer_discount_amount' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','fixed')]}"/> | ||||
|                             <field name='dealer_discount_percentage' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','percentage')]}"/> | ||||
|                             <button name="create_dealer_discount" string="Add Line" type="object" class="oe_inline fa fa-arrow-right oe_link" attrs="{'invisible': ['|',('dealer_discount','=', False), ('state','!=', 'draft')]}"/> | ||||
|                             <field name='dealer_discount_amount' style="min-width:80px;max-width:80px;width:80px;"  class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','fixed')]}"/> | ||||
|                             <field name='dealer_discount_percentage' style="min-width:50px;max-width:50px;width:50px;"  class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','percentage')]}"/> | ||||
|                             <button name="create_dealer_discount" string="Add Line" type="object" class="oe_inline fa fa-arrow-right oe_link oe_edit_only" | ||||
|                                 attrs="{'invisible': ['|',('state','not in', ['draft','sent']),('dealer_discount','=', False)]}" | ||||
|                                 style="margin-right:0px;"/> | ||||
|                         </div> | ||||
|                         <div> | ||||
|                             <button name="unset_dealer_discount" string="Remove Lines" type="object" class="oe_inline fa fa-arrow-left oe_link oe_edit_only" attrs="{'invisible': ['|',('state','not in', ['draft','sent']),('dealer_discount','=', False)]}"/> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </xpath> | ||||
|  | @ -39,7 +45,10 @@ | |||
|                             <field name='dealer_discount_type' class="oe_inline" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False), ('state','!=', 'draft')], 'required':[('dealer_discount','!=', False)]}"/> | ||||
|                             <field name='dealer_discount_amount' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','fixed')]}"/> | ||||
|                             <field name='dealer_discount_percentage' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False), ('state','!=', 'draft'),('dealer_discount_type','!=','percentage')]}"/> | ||||
|                         </div> | ||||
|                         <div> | ||||
|                             <button name="create_dealer_discount" string="Add Line" type="object" class="oe_inline fa fa-arrow-right oe_link" attrs="{'invisible': ['|',('dealer_discount','=', False), ('state','!=', 'draft')]}"/> | ||||
|                             <button name="unset_dealer_discount" string="Remove Lines" type="object" class="oe_inline fa fa-arrow-left oe_link" attrs="{'invisible': ['|',('dealer_discount','=', False), ('state','!=', 'draft')]}"/> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </xpath> | ||||
|  |  | |||
|  | @ -13,10 +13,16 @@ | |||
|                   <div name='dealer_discount'> | ||||
|                       <div> | ||||
|                         <field name='dealer_discount' class="oe_inline" nolabel="1" attrs="{'invisible': [('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <field name='dealer_discount_type' class="oe_inline" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False),'&', ('state','!=', 'draft'),('state','!=', 'sent')], 'required':[('dealer_discount','!=', False)]}"/> | ||||
|                         <field name='dealer_discount_amount' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False),('dealer_discount_type','!=','fixed'),'&', ('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <field name='dealer_discount_percentage' class="oe_inline" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False),('dealer_discount_type','!=','percentage'),'&', ('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <button name="create_dealer_discount" string="Add Line" type="object" class="oe_inline fa fa-arrow-right oe_link oe_edit_only" attrs="{'invisible': ['|',('state','not in', ['draft','sent']),('dealer_discount','=', False)]}"/> | ||||
|                         <field name='dealer_discount_product' class="oe_inline" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False),'&', ('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <field name='dealer_discount_type' class="oe_inline oe_edit_only" nolabel="1" attrs="{'invisible': ['|',('dealer_discount','=', False),'&', ('state','!=', 'draft'),('state','!=', 'sent')], 'required':[('dealer_discount','!=', False)]}"/> | ||||
|                         <field name='dealer_discount_amount' style="min-width:80px;max-width:80px;width:80px;" class="oe_inline oe_edit_only" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False),('dealer_discount_type','!=','fixed'),'&', ('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <field name='dealer_discount_percentage' style="min-width:50px;max-width:50px;width:50px;" class="oe_inline oe_edit_only" nolabel="1" attrs="{'invisible': ['|','|',('dealer_discount','=', False),('dealer_discount_type','!=','percentage'),'&', ('state','!=', 'draft'),('state','!=', 'sent')]}"/> | ||||
|                         <button name="create_dealer_discount" string="Add Line" type="object" class="oe_inline fa fa-arrow-right oe_link oe_edit_only" | ||||
|                                 attrs="{'invisible': ['|',('state','not in', ['draft','sent']),('dealer_discount','=', False)]}" | ||||
|                                 style="margin-right:0px;"/> | ||||
|                       </div> | ||||
|                       <div> | ||||
|                         <button name="unset_dealer_discount" string="Remove Lines" type="object" class="oe_inline fa fa-arrow-left oe_link oe_edit_only" attrs="{'invisible': ['|',('state','not in', ['draft','sent']),('dealer_discount','=', False)]}"/> | ||||
|                       </div> | ||||
|                   </div> | ||||
|                 </xpath> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue