我在REPAIR-ORDER的订单行中添加了多个产品,每个产品的价格都显示出来 - 但是未加税的子总数和总显示数(0)而不是所有产品的总数。
我已附上MRP REPAIR(.py)文件的部分代码:
def _amount_all_wrapper_repair(self, cr, uid, ids, field_name, arg, context=None):
""" Wrapper because of direct method passing as parameter for function fields """
return self._amount_all_repair(cr, uid, ids, field_name, arg, context=context)
def _amount_all_repair(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
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.sale_id.pricelist_id.currency_id
for line in order.order_line_ids:
val1 += line.price_subtotal
val += self._amount_line_tax_repair(cr, uid, line, context=context)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
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
mrp_repair.xml的代码:
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
<field name="amount_untaxed" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_tax" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div class="oe_subtotal_footer_separator oe_inline">
<label for="amount_total" />
<button name="button_dummy"
states="draft,sent" string="(update)" type="object" class="oe_edit_only oe_link"/>
</div>
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div class="oe_inline" groups="garage.group_display_margin">
<label for="margin" style="font-weight:bold;"/>
</div>
<field name="margin" nolabel="1" style="font-weight:bold;" groups="garage.group_display_margin"/>
</group>
我发现没有下面的代码(此代码导致MRP_REPAIR将订单行添加到REPAIR ORDER和SALES ORDER),添加价格的产品不会在总计字段中计算,并显示零(0)
elif this.repair_sale_order_line_id:
sale_obj = self.pool.get('sale.order')
so_vals = {
'partner_id' : this.repair_sale_order_line_id.partner_id.id,
'fleet_id': this.repair_sale_order_line_id.fleet_id.id,
'responsable_id': uid,
}
created_so_id = so_obj.create(cr, uid, so_vals, context=context)
sol_vals = {'order_id': created_so_id,
'price_unit': this.price_unit,
'product_uom_qty': this.product_uom_qty,
'price_subtotal': this.price_subtotal,
'discount': this.discount,
'product_id': this.product_id.id,
'tax_id': [(6, 0, [x.id for x
in this.tax_id])],
'name': this.name,
}
self.pool.get('mrp.repair').write(cr, uid, this.repair_sale_order_line_id.id, {'sale_id':created_so_id},context=context)
sol_id = sol_obj.create_sol(cr, uid, sol_vals, context)
super(repair_sale_order_line, self).write(cr, uid, [res],{'sale_order_line_id':sol_id})
似乎使用销售订单行代替内部维修销售订单行。问题是:如何使mrp不依赖于SO或其ORDER LINES。?
答案 0 :(得分:0)
我发现没有下面的代码(此代码导致MRP_REPAIR将订单行添加到REPAIR ORDER和SALES ORDER),添加价格的产品不会在总计字段中计算,并显示零(0)
elif this.repair_sale_order_line_id:
sale_obj = self.pool.get('sale.order')
so_vals = {
'partner_id' : this.repair_sale_order_line_id.partner_id.id,
'fleet_id': this.repair_sale_order_line_id.fleet_id.id,
'responsable_id': uid,
}
created_so_id = so_obj.create(cr, uid, so_vals, context=context)
sol_vals = {'order_id': created_so_id,
'price_unit': this.price_unit,
'product_uom_qty': this.product_uom_qty,
'price_subtotal': this.price_subtotal,
'discount': this.discount,
'product_id': this.product_id.id,
'tax_id': [(6, 0, [x.id for x
in this.tax_id])],
'name': this.name,
}
self.pool.get('mrp.repair').write(cr, uid, this.repair_sale_order_line_id.id, {'sale_id':created_so_id},context=context)
sol_id = sol_obj.create_sol(cr, uid, sol_vals, context)
super(repair_sale_order_line, self).write(cr, uid, [res],{'sale_order_line_id':sol_id})
似乎使用销售订单行代替内部维修销售订单行。问题是:如何使mrp不依赖于SO或其ORDER LINES。?