update track to invoice & payment from hdcase & shop
							parent
							
								
									cbe4923252
								
							
						
					
					
						commit
						b6eaefa8af
					
				| 
						 | 
					@ -9,6 +9,7 @@
 | 
				
			||||||
    <field name="parent_id"/>
 | 
					    <field name="parent_id"/>
 | 
				
			||||||
    <field name="company_id"/>
 | 
					    <field name="company_id"/>
 | 
				
			||||||
    <field name="active"/>
 | 
					    <field name="active"/>
 | 
				
			||||||
 | 
					    <field name="track_id"/>
 | 
				
			||||||
    <separator string="Address"/>
 | 
					    <separator string="Address"/>
 | 
				
			||||||
    <field name="addresses" view="form_list"/>
 | 
					    <field name="addresses" view="form_list"/>
 | 
				
			||||||
    <related>
 | 
					    <related>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
from . import clinic_setting
 | 
					from . import clinic_setting
 | 
				
			||||||
from . import print_labor_cost
 | 
					from . import update_account_tracking
 | 
				
			||||||
 | 
					#from . import print_labor_cost
 | 
				
			||||||
#from . import hdcase
 | 
					#from . import hdcase
 | 
				
			||||||
#from . import remove_conv_bal
 | 
					#from . import remove_conv_bal
 | 
				
			||||||
#from . import import_acc
 | 
					#from . import import_acc
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					from netforce.model import get_model
 | 
				
			||||||
 | 
					from netforce import migration
 | 
				
			||||||
 | 
					from netforce.access import set_active_user, set_active_company
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Migration(migration.Migration):
 | 
				
			||||||
 | 
					    _name="clinic.update.account.tracking"
 | 
				
			||||||
 | 
					    _version="2.10.0"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def migrate(self):
 | 
				
			||||||
 | 
					        set_active_user(1)
 | 
				
			||||||
 | 
					        set_active_company(1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for hdcase in get_model('clinic.hd.case').search_browse([]):
 | 
				
			||||||
 | 
					            track_id=hdcase.branch_id.track_id.id
 | 
				
			||||||
 | 
					            for payment in hdcase.payments:
 | 
				
			||||||
 | 
					                for line in payment.lines:
 | 
				
			||||||
 | 
					                    line.write({
 | 
				
			||||||
 | 
					                        'track_id': track_id,
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					            for invoice in hdcase.invoices:
 | 
				
			||||||
 | 
					                for line in invoice.lines:
 | 
				
			||||||
 | 
					                    line.write({
 | 
				
			||||||
 | 
					                        'track_id': track_id,
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					        for shop in get_model('clinic.shop').search_browse([]):
 | 
				
			||||||
 | 
					            track_id=shop.branch_id.track_id.id
 | 
				
			||||||
 | 
					            for payment in hdcase.payments:
 | 
				
			||||||
 | 
					                for line in payment.lines:
 | 
				
			||||||
 | 
					                    line.write({
 | 
				
			||||||
 | 
					                        'track_id': track_id,
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					            for invoice in hdcase.invoices:
 | 
				
			||||||
 | 
					                for line in invoice.lines:
 | 
				
			||||||
 | 
					                    line.write({
 | 
				
			||||||
 | 
					                        'track_id': track_id,
 | 
				
			||||||
 | 
					                    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Migration.register()
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@ class Branch(Model):
 | 
				
			||||||
        'departments': fields.One2Many("clinic.department","branch_id","Departments"),
 | 
					        'departments': fields.One2Many("clinic.department","branch_id","Departments"),
 | 
				
			||||||
        'active': fields.Boolean("Active"),
 | 
					        'active': fields.Boolean("Active"),
 | 
				
			||||||
        "addresses": fields.One2Many("address","related_id","Addresses"),
 | 
					        "addresses": fields.One2Many("address","related_id","Addresses"),
 | 
				
			||||||
 | 
					        "track_id": fields.Many2One("account.track.categ","Track-1",domain=[["type","=","1"]]),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    _defaults={
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -528,6 +528,7 @@ class HDCase(Model):
 | 
				
			||||||
            raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type")
 | 
					            raise Exception("No Patient Type -> Clinic Settings-> RD Shop -> Patient Type")
 | 
				
			||||||
        ptype=shop_type
 | 
					        ptype=shop_type
 | 
				
			||||||
        prod_acc=st.get_product_account
 | 
					        prod_acc=st.get_product_account
 | 
				
			||||||
 | 
					        track_id=obj.branch_id.track_id.id
 | 
				
			||||||
        for line in obj.lines:
 | 
					        for line in obj.lines:
 | 
				
			||||||
            if line.reimbursable=='no':
 | 
					            if line.reimbursable=='no':
 | 
				
			||||||
                if line.amount < 1:
 | 
					                if line.amount < 1:
 | 
				
			||||||
| 
						 | 
					@ -549,6 +550,7 @@ class HDCase(Model):
 | 
				
			||||||
                        "unit_price": line.price or 0,
 | 
					                        "unit_price": line.price or 0,
 | 
				
			||||||
                        "amount": line.amount or 0,
 | 
					                        "amount": line.amount or 0,
 | 
				
			||||||
                        'account_id': account_id,
 | 
					                        'account_id': account_id,
 | 
				
			||||||
 | 
					                        'track_id': track_id,
 | 
				
			||||||
                    }))
 | 
					                    }))
 | 
				
			||||||
        context={
 | 
					        context={
 | 
				
			||||||
            'type': 'in',
 | 
					            'type': 'in',
 | 
				
			||||||
| 
						 | 
					@ -608,7 +610,7 @@ class HDCase(Model):
 | 
				
			||||||
        normb_lines=[] #no
 | 
					        normb_lines=[] #no
 | 
				
			||||||
        cst=get_model('clinic.setting').browse(1)
 | 
					        cst=get_model('clinic.setting').browse(1)
 | 
				
			||||||
        prod_acc=cst.get_product_account
 | 
					        prod_acc=cst.get_product_account
 | 
				
			||||||
 | 
					        track_id=obj.branch_id.track_id.id
 | 
				
			||||||
        for line in obj.lines:
 | 
					        for line in obj.lines:
 | 
				
			||||||
            if line.state!='draft':
 | 
					            if line.state!='draft':
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					@ -647,6 +649,7 @@ class HDCase(Model):
 | 
				
			||||||
                    "amount": line.amount or 0,
 | 
					                    "amount": line.amount or 0,
 | 
				
			||||||
                    'account_id': account_id,
 | 
					                    'account_id': account_id,
 | 
				
			||||||
                    'ar_debit_id': ar_debit_id,
 | 
					                    'ar_debit_id': ar_debit_id,
 | 
				
			||||||
 | 
					                    'track_id': track_id,
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                normb_lines.append(('create',{
 | 
					                normb_lines.append(('create',{
 | 
				
			||||||
| 
						 | 
					@ -658,6 +661,7 @@ class HDCase(Model):
 | 
				
			||||||
                    "amount": line.amount or 0,
 | 
					                    "amount": line.amount or 0,
 | 
				
			||||||
                    'account_id': account_id,
 | 
					                    'account_id': account_id,
 | 
				
			||||||
                    'ar_debit_id': ar_debit_id,
 | 
					                    'ar_debit_id': ar_debit_id,
 | 
				
			||||||
 | 
					                    'track_id': track_id,
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        patient=obj.patient_id
 | 
					        patient=obj.patient_id
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -164,13 +164,10 @@ class ClinicSetting(Model):
 | 
				
			||||||
        if user_id !=1:
 | 
					        if user_id !=1:
 | 
				
			||||||
            print("Only admin!!")
 | 
					            print("Only admin!!")
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        sql=''
 | 
					        #for payment in get_model("account.payment").search_browse([]):
 | 
				
			||||||
        for hdcase in get_model("clinic.hd.case").search_browse([]):
 | 
					            #related=payment.related_id
 | 
				
			||||||
            for invoice in hdcase.invoices:
 | 
					            #if related:
 | 
				
			||||||
                print(hdcase.date,' ---> ', invoice.due_date)
 | 
					                
 | 
				
			||||||
                sql+="update account_invoice set due_date='%s' where id=%s;"%(hdcase.date,invoice.id)
 | 
					 | 
				
			||||||
        db=get_connection()
 | 
					 | 
				
			||||||
        db.execute(sql)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def merge_staff(self,ids,context={}):
 | 
					    def merge_staff(self,ids,context={}):
 | 
				
			||||||
        user_id=get_active_user()
 | 
					        user_id=get_active_user()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -335,6 +335,7 @@ class Shop(Model):
 | 
				
			||||||
            'partner_id': partner.id,
 | 
					            'partner_id': partner.id,
 | 
				
			||||||
            "lines": [],
 | 
					            "lines": [],
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        track_id=obj.branch_id.track_id.id
 | 
				
			||||||
        for line in obj.lines:
 | 
					        for line in obj.lines:
 | 
				
			||||||
            if line.amount < 1:
 | 
					            if line.amount < 1:
 | 
				
			||||||
                continue
 | 
					                continue
 | 
				
			||||||
| 
						 | 
					@ -355,6 +356,7 @@ class Shop(Model):
 | 
				
			||||||
                    "amount": line.amount or 0,
 | 
					                    "amount": line.amount or 0,
 | 
				
			||||||
                    'account_id': account_id,
 | 
					                    'account_id': account_id,
 | 
				
			||||||
                    'ar_debit_id': ar_debit_id,
 | 
					                    'ar_debit_id': ar_debit_id,
 | 
				
			||||||
 | 
					                    'track_id': track_id,
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
        inv_id=get_model("account.invoice").create(vals,context=context)
 | 
					        inv_id=get_model("account.invoice").create(vals,context=context)
 | 
				
			||||||
        inv=get_model("account.invoice").browse(inv_id)
 | 
					        inv=get_model("account.invoice").browse(inv_id)
 | 
				
			||||||
| 
						 | 
					@ -471,6 +473,7 @@ class Shop(Model):
 | 
				
			||||||
            'direct_lines': [],
 | 
					            'direct_lines': [],
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        prod_acc=cst.get_product_account
 | 
					        prod_acc=cst.get_product_account
 | 
				
			||||||
 | 
					        track_id=obj.branch_id.track_id.id
 | 
				
			||||||
        for line in obj.lines:
 | 
					        for line in obj.lines:
 | 
				
			||||||
            prod=line.product_id
 | 
					            prod=line.product_id
 | 
				
			||||||
            acc=prod_acc(prod.id,shop_type.id,'cash')
 | 
					            acc=prod_acc(prod.id,shop_type.id,'cash')
 | 
				
			||||||
| 
						 | 
					@ -487,6 +490,7 @@ class Shop(Model):
 | 
				
			||||||
                    "unit_price": line.price or 0,
 | 
					                    "unit_price": line.price or 0,
 | 
				
			||||||
                    "amount": line.amount or 0,
 | 
					                    "amount": line.amount or 0,
 | 
				
			||||||
                    'account_id': account_id,
 | 
					                    'account_id': account_id,
 | 
				
			||||||
 | 
					                    'track_id': track_id,
 | 
				
			||||||
                }))
 | 
					                }))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        context={
 | 
					        context={
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue