Add discount value in move out for the sale line
This commit is contained in:
parent
35598b7304
commit
fb76989d89
|
@ -1,4 +1,5 @@
|
|||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
|
||||
from move import *
|
||||
from sale import *
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
''',
|
||||
'depends': [
|
||||
'sale',
|
||||
'account_invoice_discount'
|
||||
'account_invoice_discount',
|
||||
],
|
||||
'xml': [
|
||||
'sale.xml'
|
||||
'move.xml',
|
||||
'sale.xml',
|
||||
],
|
||||
'translation': [
|
||||
'locale/ca_ES.po',
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
|
||||
from decimal import Decimal
|
||||
from trytond.model import ModelView, ModelSQL, fields
|
||||
from trytond.pyson import Not, Equal, Eval
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
|
||||
class Move(ModelSQL, ModelView):
|
||||
_name = 'stock.move'
|
||||
|
||||
discount = fields.Numeric('Discount %', digits=(16, 4),
|
||||
states={
|
||||
'readonly': Not(Equal(Eval('state'), 'draft')),
|
||||
},
|
||||
depends=['state'])
|
||||
|
||||
Move()
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="move_view_form">
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit" ref="stock.move_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/label[@name="unit_price"]"
|
||||
position="before">
|
||||
<newline/>
|
||||
<label name="discount"/>
|
||||
<field name="discount"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
9
sale.py
9
sale.py
|
@ -57,6 +57,15 @@ class SaleLine(ModelSQL, ModelView):
|
|||
res[0]['discount'] = line.discount
|
||||
return [res[0]]
|
||||
|
||||
def get_move(self, line, shipment_type):
|
||||
'''
|
||||
Add discount value in move out for the sale line
|
||||
'''
|
||||
res = super(SaleLine, self).get_move(line, shipment_type)
|
||||
if line.discount and shipment_type == 'out':
|
||||
res['discount'] = line.discount
|
||||
return res
|
||||
|
||||
SaleLine()
|
||||
|
||||
class Sale(ModelSQL, ModelView):
|
||||
|
|
Loading…
Reference in New Issue