-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_category__reset.go
71 lines (57 loc) · 1.93 KB
/
product_category__reset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package odooconn
import (
"fmt"
"strings"
)
// ProductCategoryConsumable3 function
func (o *OdooConn) ProductCategoryReset() {
mdl := "product_category"
umdl := strings.Replace(mdl, "_", ".", -1)
fmt.Printf("\n%v\nconsumables3\n", umdl)
odoorecs, err := o.SearchRead(umdl, oarg{}, 0, 0, []string{"display_name"})
o.checkErr(err)
fmt.Println("product.categories:", len(odoorecs))
odooIDs, err := o.Search(umdl, oarg{})
o.checkErr(err)
fmt.Println("product.categories:", len(odooIDs))
// bar := progressbar.Default(int64(recs))
incCode, err := o.GetID("account.account", oarg{oarg{"code", "=", "420000"}})
o.checkErr(err)
expCode, err := o.GetID("account.account", oarg{oarg{"code", "=", "511100"}})
o.checkErr(err)
// tasker
// wg.Add(recs)
for _, r := range odooIDs {
// pid := o.GetID(umdl, oarg{oarg{"name", "=", v.Group1}, oarg{"parent_id", "=", allID}})
// sid := -1
// if pid != -1 {
// sid = o.GetID(umdl, oarg{oarg{"name", "=", v.Group2}, oarg{"parent_id", "=", pid}})
// }
// gid := -1
// if sid != -1 {
// gid = o.GetID(umdl, oarg{oarg{"name", "=", v.Matgrp}, oarg{"parent_id", "=", sid}})
// with buyer id setting
// bidPartner := o.GetID("res.partner", oarg{oarg{"name", "=", v.Buyer}})
// bid := o.GetID("res.users", oarg{oarg{"partner_id", "=", bidPartner}})
ur := map[string]interface{}{
// "name": v.Matgrp,
// "parent_id": sid,
// "property_cost_method": v.PropertyCostMethod,
// "property_valuation": "real_time",
"property_account_income_categ_id": incCode,
"property_account_expense_categ_id": expCode,
}
// with buyer id setting
// if v.Matkl != "" {
// ur["material_group"] = v.Matkl
// }
// if v.DayReview != "" {
// ur["review_day"] = v.DayReview
// }
// if bid != -1 {
// ur["buyer_id"] = bid
// }
o.Log.Info(umdl, "record", ur, "r", r)
o.Record(umdl, r, ur)
}
}