0
구매 주문 행에 새 필드를 추가하기 위해 구매 모듈을 수정합니다. 모델을 만들고 사용자 정의 필드를 볼 수있는 코드를 성공적으로 추가했습니다. 그러나 P.O.의 총 금액에 사용자 정의 필드를 추가 할 수 없습니다. 선.사용자 정의 OpenERP 모듈이 의도 한대로 작동하지 않습니다.
class customPo(osv.osv):
_inherit="purchase.order"
#_name = 'customPo'
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
res = {}
cur_obj=self.pool.get('res.currency')
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
val = val1 = 0.0
cur = order.pricelist_id.currency_id
for line in order.order_line:
# val1 += line.price_subtotal
val1 = val1 + line.data + line.price_subtotal
for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id, order.partner_id)['taxes']:
val += c.get('amount', 0.0)
res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, 42.0)
res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
return res
_columns = {
'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines', states={'approved':[('readonly',True)],'done':[('readonly',True)]}),
'amount_untaxed': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Untaxed Amount',
store={
'purchase.order.line': (_get_order, None, 10),
}, multi="sums", help="The amount without tax", track_visibility='always'),
'amount_tax': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Taxes',
store={
'purchase.order.line': (_get_order, None, 10),
}, multi="sums", help="The tax amount"),
'amount_total': fields.function(_amount_all, digits_compute= dp.get_precision('Account'), string='Total',
store={
'purchase.order.line': (_get_order, None, 10),
}, multi="sums",help="The total amount"),
}
customPo()
class customPol(osv.osv):
_inherit = 'purchase.order.line'
# _name = 'something.notpurchase'
_columns = {
'data': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),
}
customPol()
저는 세금이 42로 고정되어 있으므로 재정의 된 메소드가 호출 될 때 알 수 있지만 결코 발생하지 않습니다.
보기 파일은 다음과 같습니다.
는<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="custom_purchse_wa" model="ir.ui.view">
<field name="name">Custom Field New</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_unit']" position="after">
<field name="data" string="Custom field"/>
</xpath>
</field>
</record>
</data>
</openerp>
에 계산을 할 수는 뷰에서 필드를 볼 수 있습니다 ? 그렇다면 필드 데이터에 대한 float 변수를 지정할 수 있습니까? 이 데이터가 데이터베이스에 입력되었는지 여부를 확인하십시오. – OmaL
> 뷰에서 필드를 볼 수 있고, 데이터를 db에 추가 할 수 있으며, purchase.py (inbuilt 모듈)를 수정하여 해당 데이터를 내 총계에 추가 할 수 있습니다.하지만 challange (표준 절차)는 원래 purchasy.py를 수정하지 않고도 동일한 작업을 수행하는 것입니다. –
@AshokKumarSahoo이 값을 구매 주문서에 추가하고 세금, 총액과 같은 모든 계산 작업을 성공시킬 수 있습니까? 예일 경우 여기에 코드를 추가하십시오. –