shop
parent
1fcc52bbb6
commit
72b440b69c
|
@ -39,10 +39,27 @@
|
|||
<field name="amount"/>
|
||||
</list>
|
||||
</field>
|
||||
<group span="9" columns="1">
|
||||
<group span="8" columns="1">
|
||||
</group>
|
||||
<group span="3" columns="1">
|
||||
<group span="4" columns="1">
|
||||
<field name="sub_total"/>
|
||||
<field name="tax_amount"/>
|
||||
<field name="total"/>
|
||||
<field name="payment_lines">
|
||||
<template>
|
||||
{{#each context.data}}
|
||||
<div class="form-group nf-field">
|
||||
<label class="control-label col-md-4">Less
|
||||
<a href="#name=payment&mode=form&active_id={{payment_id.0.}}">Payment</a>
|
||||
</label>
|
||||
<div class="col-md-8" style="text-align:right">
|
||||
{{currency amount}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
</template>
|
||||
</field>
|
||||
<field name="due_amount"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Accounting">
|
||||
|
|
|
@ -116,6 +116,7 @@ from . import matching_hdcase
|
|||
from . import sale_order
|
||||
from . import shop
|
||||
from . import shop_line
|
||||
from . import shop_payment
|
||||
from . import product
|
||||
from . import base_user
|
||||
from . import select_company
|
||||
|
|
|
@ -16,12 +16,20 @@ class Shop(Model):
|
|||
st=get_model("clinic.setting").browse(1)
|
||||
shop_categs=[x.id for x in st.shop_categs]
|
||||
for obj in self.browse(ids):
|
||||
total=0
|
||||
sub_total=0
|
||||
tax_amount=0 #XXX
|
||||
for line in obj.lines:
|
||||
amt=line.amount or 0
|
||||
total+=amt
|
||||
sub_total+=amt
|
||||
total=sub_total
|
||||
total=total-tax_amount
|
||||
for pm in obj.payments:
|
||||
total-=pm.amount_payment
|
||||
res[obj.id]={
|
||||
'sub_total': sub_total,
|
||||
'tax_amount': tax_amount,
|
||||
'total': total,
|
||||
'due_amount': total,
|
||||
'shop_categs': shop_categs,
|
||||
}
|
||||
return res
|
||||
|
@ -36,7 +44,10 @@ class Shop(Model):
|
|||
'department_id': fields.Many2One("clinic.department","Department",search=True),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch",search=True),
|
||||
'lines': fields.One2Many('clinic.shop.line','shop_id','Lines'),
|
||||
'sub_total': fields.Float("Subtotal",function="_get_all",function_multi=True),
|
||||
'total': fields.Float("Total",function="_get_all",function_multi=True),
|
||||
'due_amount': fields.Float("Due Amount",function="_get_all",function_multi=True),
|
||||
'tax_amount': fields.Float("Tax Amount",function="_get_all",function_multi=True),
|
||||
'user_id': fields.Many2One("base.user","Sale Man"),
|
||||
'state': fields.Selection([['draft','Draft'],['waiting_payment','Waiting Payment'],['paid','Paid'],['cancelled','Cancelled']],'State'),
|
||||
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
|
||||
|
@ -54,6 +65,7 @@ class Shop(Model):
|
|||
'cheque_no': fields.Char("Cheque No."),
|
||||
'hd_case_call': fields.Boolean("HD Case Call"),
|
||||
'note': fields.Text("Note"),
|
||||
"payment_lines": fields.One2Many("clinic.shop.payment","shop_id","Payment Lines"),
|
||||
}
|
||||
|
||||
|
||||
|
@ -450,6 +462,10 @@ class Shop(Model):
|
|||
obj.write({
|
||||
'state': 'paid',
|
||||
'pay_type': 'cash',
|
||||
'payment_lines': [('create',{
|
||||
'payment_id': payment_id,
|
||||
'amount': payment.amount_payment,
|
||||
})],
|
||||
})
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
|
@ -468,6 +484,8 @@ class Shop(Model):
|
|||
for picking in obj.pickings:
|
||||
picking.to_draft(context=context)
|
||||
picking.delete()
|
||||
for pm_line in obj.payment_lines:
|
||||
pm_line.delete()
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class ShopPayment(Model):
|
||||
_name="clinic.shop.payment"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'shop_id': fields.Many2One("clinic.hd.case","HD Case",on_delete="cascade"),
|
||||
'payment_id': fields.Many2One("account.payment","Payment",on_delete="cascade"),
|
||||
'account_id': fields.Many2One("account.account","Account"),
|
||||
'amount': fields.Float("Amount"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'amount': 0.0,
|
||||
}
|
||||
|
||||
ShopPayment.register()
|
||||
|
Loading…
Reference in New Issue