-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathreport_product_report_pricelist.go
114 lines (98 loc) · 4.68 KB
/
report_product_report_pricelist.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package odoo
import (
"fmt"
)
// ReportProductReportPricelist represents report.product.report_pricelist model.
type ReportProductReportPricelist struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
}
// ReportProductReportPricelists represents array of report.product.report_pricelist model.
type ReportProductReportPricelists []ReportProductReportPricelist
// ReportProductReportPricelistModel is the odoo model name.
const ReportProductReportPricelistModel = "report.product.report_pricelist"
// Many2One convert ReportProductReportPricelist to *Many2One.
func (rpr *ReportProductReportPricelist) Many2One() *Many2One {
return NewMany2One(rpr.Id.Get(), "")
}
// CreateReportProductReportPricelist creates a new report.product.report_pricelist model and returns its id.
func (c *Client) CreateReportProductReportPricelist(rpr *ReportProductReportPricelist) (int64, error) {
return c.Create(ReportProductReportPricelistModel, rpr)
}
// UpdateReportProductReportPricelist updates an existing report.product.report_pricelist record.
func (c *Client) UpdateReportProductReportPricelist(rpr *ReportProductReportPricelist) error {
return c.UpdateReportProductReportPricelists([]int64{rpr.Id.Get()}, rpr)
}
// UpdateReportProductReportPricelists updates existing report.product.report_pricelist records.
// All records (represented by ids) will be updated by rpr values.
func (c *Client) UpdateReportProductReportPricelists(ids []int64, rpr *ReportProductReportPricelist) error {
return c.Update(ReportProductReportPricelistModel, ids, rpr)
}
// DeleteReportProductReportPricelist deletes an existing report.product.report_pricelist record.
func (c *Client) DeleteReportProductReportPricelist(id int64) error {
return c.DeleteReportProductReportPricelists([]int64{id})
}
// DeleteReportProductReportPricelists deletes existing report.product.report_pricelist records.
func (c *Client) DeleteReportProductReportPricelists(ids []int64) error {
return c.Delete(ReportProductReportPricelistModel, ids)
}
// GetReportProductReportPricelist gets report.product.report_pricelist existing record.
func (c *Client) GetReportProductReportPricelist(id int64) (*ReportProductReportPricelist, error) {
rprs, err := c.GetReportProductReportPricelists([]int64{id})
if err != nil {
return nil, err
}
if rprs != nil && len(*rprs) > 0 {
return &((*rprs)[0]), nil
}
return nil, fmt.Errorf("id %v of report.product.report_pricelist not found", id)
}
// GetReportProductReportPricelists gets report.product.report_pricelist existing records.
func (c *Client) GetReportProductReportPricelists(ids []int64) (*ReportProductReportPricelists, error) {
rprs := &ReportProductReportPricelists{}
if err := c.Read(ReportProductReportPricelistModel, ids, nil, rprs); err != nil {
return nil, err
}
return rprs, nil
}
// FindReportProductReportPricelist finds report.product.report_pricelist record by querying it with criteria.
func (c *Client) FindReportProductReportPricelist(criteria *Criteria) (*ReportProductReportPricelist, error) {
rprs := &ReportProductReportPricelists{}
if err := c.SearchRead(ReportProductReportPricelistModel, criteria, NewOptions().Limit(1), rprs); err != nil {
return nil, err
}
if rprs != nil && len(*rprs) > 0 {
return &((*rprs)[0]), nil
}
return nil, fmt.Errorf("no report.product.report_pricelist was found with criteria %v", criteria)
}
// FindReportProductReportPricelists finds report.product.report_pricelist records by querying it
// and filtering it with criteria and options.
func (c *Client) FindReportProductReportPricelists(criteria *Criteria, options *Options) (*ReportProductReportPricelists, error) {
rprs := &ReportProductReportPricelists{}
if err := c.SearchRead(ReportProductReportPricelistModel, criteria, options, rprs); err != nil {
return nil, err
}
return rprs, nil
}
// FindReportProductReportPricelistIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindReportProductReportPricelistIds(criteria *Criteria, options *Options) ([]int64, error) {
ids, err := c.Search(ReportProductReportPricelistModel, criteria, options)
if err != nil {
return []int64{}, err
}
return ids, nil
}
// FindReportProductReportPricelistId finds record id by querying it with criteria.
func (c *Client) FindReportProductReportPricelistId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(ReportProductReportPricelistModel, criteria, options)
if err != nil {
return -1, err
}
if len(ids) > 0 {
return ids[0], nil
}
return -1, fmt.Errorf("no report.product.report_pricelist was found with criteria %v and options %v", criteria, options)
}