Add discount value in move out for the sale line

This commit is contained in:
resteve 2012-07-16 16:04:15 +02:00
parent 35598b7304
commit fb76989d89
5 changed files with 56 additions and 2 deletions

View File

@ -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 *

View File

@ -27,10 +27,11 @@
''',
'depends': [
'sale',
'account_invoice_discount'
'account_invoice_discount',
],
'xml': [
'sale.xml'
'move.xml',
'sale.xml',
],
'translation': [
'locale/ca_ES.po',

19
move.py Normal file
View File

@ -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()

24
move.xml Normal file
View File

@ -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=&quot;unit_price&quot;]"
position="before">
<newline/>
<label name="discount"/>
<field name="discount"/>
</xpath>
</data>
]]>
</field>
</record>
</data>
</tryton>

View File

@ -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):