diff --git a/netforce_clinic/actions/clinic_department_product.xml b/netforce_clinic/actions/clinic_department_product.xml
new file mode 100644
index 0000000..b357a02
--- /dev/null
+++ b/netforce_clinic/actions/clinic_department_product.xml
@@ -0,0 +1,6 @@
+
+ Department Product
+ multi_view
+ clinic.department.product
+ clinic_menu
+
diff --git a/netforce_clinic/layouts/clinic_department_prod_form.xml b/netforce_clinic/layouts/clinic_department_prod_form.xml
new file mode 100644
index 0000000..2167eed
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_department_prod_form.xml
@@ -0,0 +1,5 @@
+
diff --git a/netforce_clinic/layouts/clinic_department_prod_list.xml b/netforce_clinic/layouts/clinic_department_prod_list.xml
new file mode 100644
index 0000000..bb26cfa
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_department_prod_list.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index fa4e6cc..d400c2a 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -49,16 +49,12 @@
-
-
-
-
-
-
+
diff --git a/netforce_clinic/layouts/clinic_prod_form.xml b/netforce_clinic/layouts/clinic_prod_form.xml
index b507674..ed2a5e8 100644
--- a/netforce_clinic/layouts/clinic_prod_form.xml
+++ b/netforce_clinic/layouts/clinic_prod_form.xml
@@ -2,14 +2,4 @@
-
-
-
-
-
-
-
-
diff --git a/netforce_clinic/layouts/clinic_setting_account_prod_form.xml b/netforce_clinic/layouts/clinic_setting_account_prod_form.xml
index 014ef49..947239d 100644
--- a/netforce_clinic/layouts/clinic_setting_account_prod_form.xml
+++ b/netforce_clinic/layouts/clinic_setting_account_prod_form.xml
@@ -1,8 +1,9 @@
diff --git a/netforce_clinic/layouts/clinic_setting_account_prod_list.xml b/netforce_clinic/layouts/clinic_setting_account_prod_list.xml
index 4dfb6bf..4b4fef4 100644
--- a/netforce_clinic/layouts/clinic_setting_account_prod_list.xml
+++ b/netforce_clinic/layouts/clinic_setting_account_prod_list.xml
@@ -1,6 +1,7 @@
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 114069a..b797965 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -11,6 +11,7 @@ from . import cause_chronic
from . import comorbidity
from . import department
from . import department_profile
+from . import department_product
from . import education
from . import graduation
from . import morbidity
@@ -131,4 +132,3 @@ from . import report_shop
from . import account_tax_component
from . import report_thai_wht_certif
from . import num2word
-from . import department_product
diff --git a/netforce_clinic/models/department_product.py b/netforce_clinic/models/department_product.py
index 34c6d1c..addfb93 100644
--- a/netforce_clinic/models/department_product.py
+++ b/netforce_clinic/models/department_product.py
@@ -3,10 +3,20 @@ from netforce.model import Model, fields
class DepartmentProduct(Model):
_name="clinic.department.product"
_string="Department Product"
-
+ _key=['product_id','department_id']
_fields={
- "product_id": fields.Many2One("product","Product"),
- "department_id": fields.Many2One("clinic.department","Department"),
+ "product_id": fields.Many2One("product","Product", required=True),
+ "department_id": fields.Many2One("clinic.department","Working Department", required=True),
+ "stock_journal_id": fields.Many2One("stock.journal","Stock Journal",required=True),
}
+
+ def get_location(self,department_id,product_id,context={}):
+ for obj in self.search_browse([]):
+ if obj.department_id.id==department_id and obj.product_id.id==product_id:
+ return {
+ 'wh_loc_id': obj.stock_journal_id.location_from_id.id,
+ 'cust_loc_id': obj.stock_journal_id.location_to_id.id,
+ 'journal_id': obj.stock_journal_id.id,
+ }
DepartmentProduct.register()
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 04d8fd1..f56fd6b 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -786,15 +786,20 @@ class HDCase(Model):
if prod_ids and prod.id not in prod_ids or prod.id in prod_exist_ids:
continue
prod_exist_ids.append(prod.id)
-
+ #XXX
+ dpt_prods=get_model('clinic.department.product').get_location(obj.department_id.id,prod.id)
+ if dpt_prods:
+ print("get location from menu department products")
+ wh_loc_id=dpt_prods.get('wh_loc_id')
+ cust_loc_id=dpt_prods.get('cust_loc_id')
+ #pick_vals['journal_id']=dpt_prods.get('journal_id')
if not wh_loc_id:
wh_loc_id=prod.location_id.id
- if not wh_loc_id:
+ if wh_loc_id:
res=get_model("stock.location").search([["type","=","internal"]])
if not res:
raise Exception("Warehouse not found")
wh_loc_id=res[0]
-
line_vals={
"product_id": prod.id,
"qty": line.qty,
@@ -802,9 +807,6 @@ class HDCase(Model):
"location_from_id": wh_loc_id,
"location_to_id": cust_loc_id,
}
- #XXX wharehouse in profile product
- if prod.location_id:
- line_vals['location_from_id']=prod.location_id.id
pick_vals["lines"].append(("create",line_vals))
if not pick_vals["lines"]:
return {
diff --git a/netforce_clinic/models/shop.py b/netforce_clinic/models/shop.py
index 7b483ce..105a214 100644
--- a/netforce_clinic/models/shop.py
+++ b/netforce_clinic/models/shop.py
@@ -68,7 +68,8 @@ class Shop(Model):
"payment_lines": fields.One2Many("clinic.shop.payment","shop_id","Payment Lines"),
}
-
+ _order="date desc"
+
def _get_shop_categs(self,context={}):
st=get_model("clinic.setting").browse(1)
shop_categs=[x.id for x in st.shop_categs]