|
| 1 | +package odoo |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | +) |
| 6 | + |
| 7 | +// AccountAbstractPayment represents account.abstract.payment model. |
| 8 | +type AccountAbstractPayment struct { |
| 9 | + LastUpdate *Time `xmlrpc:"__last_update,omitempty"` |
| 10 | + Amount *Float `xmlrpc:"amount,omitempty"` |
| 11 | + Communication *String `xmlrpc:"communication,omitempty"` |
| 12 | + CompanyId *Many2One `xmlrpc:"company_id,omitempty"` |
| 13 | + CurrencyId *Many2One `xmlrpc:"currency_id,omitempty"` |
| 14 | + DisplayName *String `xmlrpc:"display_name,omitempty"` |
| 15 | + HidePaymentMethod *Bool `xmlrpc:"hide_payment_method,omitempty"` |
| 16 | + Id *Int `xmlrpc:"id,omitempty"` |
| 17 | + JournalId *Many2One `xmlrpc:"journal_id,omitempty"` |
| 18 | + PartnerId *Many2One `xmlrpc:"partner_id,omitempty"` |
| 19 | + PartnerType *Selection `xmlrpc:"partner_type,omitempty"` |
| 20 | + PaymentDate *Time `xmlrpc:"payment_date,omitempty"` |
| 21 | + PaymentMethodCode *String `xmlrpc:"payment_method_code,omitempty"` |
| 22 | + PaymentMethodId *Many2One `xmlrpc:"payment_method_id,omitempty"` |
| 23 | + PaymentType *Selection `xmlrpc:"payment_type,omitempty"` |
| 24 | +} |
| 25 | + |
| 26 | +// AccountAbstractPayments represents array of account.abstract.payment model. |
| 27 | +type AccountAbstractPayments []AccountAbstractPayment |
| 28 | + |
| 29 | +// AccountAbstractPaymentModel is the odoo model name. |
| 30 | +const AccountAbstractPaymentModel = "account.abstract.payment" |
| 31 | + |
| 32 | +// Many2One convert AccountAbstractPayment to *Many2One. |
| 33 | +func (aap *AccountAbstractPayment) Many2One() *Many2One { |
| 34 | + return NewMany2One(aap.Id.Get(), "") |
| 35 | +} |
| 36 | + |
| 37 | +// CreateAccountAbstractPayment creates a new account.abstract.payment model and returns its id. |
| 38 | +func (c *Client) CreateAccountAbstractPayment(aap *AccountAbstractPayment) (int64, error) { |
| 39 | + return c.Create(AccountAbstractPaymentModel, aap) |
| 40 | +} |
| 41 | + |
| 42 | +// UpdateAccountAbstractPayment updates an existing account.abstract.payment record. |
| 43 | +func (c *Client) UpdateAccountAbstractPayment(aap *AccountAbstractPayment) error { |
| 44 | + return c.UpdateAccountAbstractPayments([]int64{aap.Id.Get()}, aap) |
| 45 | +} |
| 46 | + |
| 47 | +// UpdateAccountAbstractPayments updates existing account.abstract.payment records. |
| 48 | +// All records (represented by ids) will be updated by aap values. |
| 49 | +func (c *Client) UpdateAccountAbstractPayments(ids []int64, aap *AccountAbstractPayment) error { |
| 50 | + return c.Update(AccountAbstractPaymentModel, ids, aap) |
| 51 | +} |
| 52 | + |
| 53 | +// DeleteAccountAbstractPayment deletes an existing account.abstract.payment record. |
| 54 | +func (c *Client) DeleteAccountAbstractPayment(id int64) error { |
| 55 | + return c.DeleteAccountAbstractPayments([]int64{id}) |
| 56 | +} |
| 57 | + |
| 58 | +// DeleteAccountAbstractPayments deletes existing account.abstract.payment records. |
| 59 | +func (c *Client) DeleteAccountAbstractPayments(ids []int64) error { |
| 60 | + return c.Delete(AccountAbstractPaymentModel, ids) |
| 61 | +} |
| 62 | + |
| 63 | +// GetAccountAbstractPayment gets account.abstract.payment existing record. |
| 64 | +func (c *Client) GetAccountAbstractPayment(id int64) (*AccountAbstractPayment, error) { |
| 65 | + aaps, err := c.GetAccountAbstractPayments([]int64{id}) |
| 66 | + if err != nil { |
| 67 | + return nil, err |
| 68 | + } |
| 69 | + if aaps != nil && len(*aaps) > 0 { |
| 70 | + return &((*aaps)[0]), nil |
| 71 | + } |
| 72 | + return nil, fmt.Errorf("id %v of account.abstract.payment not found", id) |
| 73 | +} |
| 74 | + |
| 75 | +// GetAccountAbstractPayments gets account.abstract.payment existing records. |
| 76 | +func (c *Client) GetAccountAbstractPayments(ids []int64) (*AccountAbstractPayments, error) { |
| 77 | + aaps := &AccountAbstractPayments{} |
| 78 | + if err := c.Read(AccountAbstractPaymentModel, ids, nil, aaps); err != nil { |
| 79 | + return nil, err |
| 80 | + } |
| 81 | + return aaps, nil |
| 82 | +} |
| 83 | + |
| 84 | +// FindAccountAbstractPayment finds account.abstract.payment record by querying it with criteria. |
| 85 | +func (c *Client) FindAccountAbstractPayment(criteria *Criteria) (*AccountAbstractPayment, error) { |
| 86 | + aaps := &AccountAbstractPayments{} |
| 87 | + if err := c.SearchRead(AccountAbstractPaymentModel, criteria, NewOptions().Limit(1), aaps); err != nil { |
| 88 | + return nil, err |
| 89 | + } |
| 90 | + if aaps != nil && len(*aaps) > 0 { |
| 91 | + return &((*aaps)[0]), nil |
| 92 | + } |
| 93 | + return nil, fmt.Errorf("no account.abstract.payment was found with criteria %v", criteria) |
| 94 | +} |
| 95 | + |
| 96 | +// FindAccountAbstractPayments finds account.abstract.payment records by querying it |
| 97 | +// and filtering it with criteria and options. |
| 98 | +func (c *Client) FindAccountAbstractPayments(criteria *Criteria, options *Options) (*AccountAbstractPayments, error) { |
| 99 | + aaps := &AccountAbstractPayments{} |
| 100 | + if err := c.SearchRead(AccountAbstractPaymentModel, criteria, options, aaps); err != nil { |
| 101 | + return nil, err |
| 102 | + } |
| 103 | + return aaps, nil |
| 104 | +} |
| 105 | + |
| 106 | +// FindAccountAbstractPaymentIds finds records ids by querying it |
| 107 | +// and filtering it with criteria and options. |
| 108 | +func (c *Client) FindAccountAbstractPaymentIds(criteria *Criteria, options *Options) ([]int64, error) { |
| 109 | + ids, err := c.Search(AccountAbstractPaymentModel, criteria, options) |
| 110 | + if err != nil { |
| 111 | + return []int64{}, err |
| 112 | + } |
| 113 | + return ids, nil |
| 114 | +} |
| 115 | + |
| 116 | +// FindAccountAbstractPaymentId finds record id by querying it with criteria. |
| 117 | +func (c *Client) FindAccountAbstractPaymentId(criteria *Criteria, options *Options) (int64, error) { |
| 118 | + ids, err := c.Search(AccountAbstractPaymentModel, criteria, options) |
| 119 | + if err != nil { |
| 120 | + return -1, err |
| 121 | + } |
| 122 | + if len(ids) > 0 { |
| 123 | + return ids[0], nil |
| 124 | + } |
| 125 | + return -1, fmt.Errorf("no account.abstract.payment was found with criteria %v and options %v", criteria, options) |
| 126 | +} |
0 commit comments