Adding feature to Quotes

Hi,

I’m working to add a feature to Quotes Module (see attached image), the idea is to make visible the field cost, and add a field for utility or profit (however you want to call it), in order that you write the cost of your product and the utility as a percentage or as a value. The idea is to make this feature public in order it could be included on SuiteCRM future releases, if the community find it useful.

And as discount or tax fields the list price got calculated according to the cost and utility chosen, e.g.: if cost is 100$ and utility is 30%, list price will be 142,86$, or if cost is 100$ and utility is 30$ the list price will be 130.

I’ve succesfully edited the file line_items.js, now I need to create the fields on the database.

How is the best way to add this fields? Using Studio? or should I just add the field to the table aos_products_quotes?

Thanks for your guidance, is the first time i’m trying to develop a feature to SuiteCRM.

You can add them in Studio, but they will be created as Custom fields in a secondary table (the module name + ending in _cstm).

Or you can add them in the Vardefs for the module and then do a Quick Repair and Rebuild (scroll down to the bottom, press button to sync database with vardefs).

1 Like

mmm Vardefs, ok, I was sure that there should exist something like that, but didn’t know where, thank you, I will take a look at this and let you know

You need to read the Developer Guide, you will learn a lot from there:

https://suitecrm.com/wiki/index.php/Developer_Guide

Wow, a lot to read!, but awesome, that will help me a lot.

I’ve just found the coding standards https://suitecrm.com/wiki/index.php/Coding_Standards, and the GIT guide to clone and fork the code.

The vardefs works, thankyou, I see the new fields created on the database, also I see that new fields were added to the module Line Items on Studio, I edited the labels, because first it appears with the same name of the label on CAPITALS and separeted_by_underscore, so I change this for the correct text that I expect to be displayed on the UI, but I don’t see that changes were reflected on UI, obviously I’ve done quick repair & rebuild twice after changes and also rebuild JavaScript languajes.

As I’m working on AOS_Products_Quotes module, I don’t see that on ./language/en_us.lang.php the new fields were added, should I add them manually or should I expect that Studio do it for me when I had edited the Line Items module using Studio?

You need to “Save and Deploy” when changing the fields, did you do that always?

Studio won’t change anything directly in “modules” or “include” directories, it will create additional files in “custom”.

You can check what Studio is doing, you might learn a lot:

https://pgorod.github.io/Audit-File-Accesses/

Yes I’ve save&deploy always, maybe i’m missing something. Will check the link of file audit and let you know, thanks.

Ok, I think I’m done, it seems that everything is working as expected, now I need to do some tests.

But I have a doubt, because is the first time that I will push to SuiteCRM project.

I’ve read https://help.github.com/articles/pushing-to-a-remote/ and https://suitecrm.com/wiki/index.php/Contributing_to_SuiteCRM

But I’m not sure if I’m doing it good, I execute:

$ git checkout master
$ git fetch upstream
$ git merge upstream/master
$ git push origin master

Now I don’t know how to push or commit or pull those changes to SuiteCRM for approval

Thanks for your help in advance.

You don’t push to master, only the maintainers can do that.

  • you push bug fixes to hotfix-7.8.x if it’s meant for the LTS branch (7.8),
  • or you push bug fixes to hotfix if it’s meant for the 7.9 branch
  • or you push new features to develop branch

Another thing, instead of doing fetch, then merge, do it in a single command with “pull”.

Hi @pgr,

Thanks for your answer, maybe I don’t explain myself properly, I don’t understand all terms and process with github yet, the merge was made to my own fork, so as I understand I’ve made changes on my own machine and upload it to my own fork of SuiteCRM, now I’ve opened a pull request for my changes to be merged to SuiteCRM master branch.

As I understand now SuiteCRM will review my changes, test and if you find it useful and correct it will be merged into the SuiteCRM into a next version.

Pull request was https://github.com/salesagility/SuiteCRM/pull/5140

Thanks for the guide. I hope this contribution to be useful to everybody.

Thanks, but you’ll need to do some more work on that PR :slight_smile:

You shouldn’t be using your master branch, you should sub-branch and work there, to keep things separate. But this is just a matter of your organization of your own repo.

Then you shouldn’t do the PR directed at the master branch of SuiteCRM, but at those other branches I mentioned above.

And you shouldn’t include style.css in your push, it’s SASS generated from changes done in other files.

This is a lot to learn when you’re just starting, but take it step by step and you’ll get there. I will be gone for almost a week now,m but I’m sure Dillon or one of the others in the team will answer your PR asking for these changes.

Thanks for contributing!

Hi @pgr,

I have some questions after the PR.

  1. I’ve changed the PR to hotfix-7.9.x, but from my master to hotfix-7.9.x, but you said that I should not use my master branch, so how can I move/convert/copy my master to a branch
  2. Now SuiteCRM 7.10.1 was released, and I have new features and changes to add, but I don’t know how to update/synchronize my repo with the latest 7.10.X, and start from there to write the new changes.

I’m not sure if I’d been clear enough, Git is complicated to me.

Thanks for your help.

David.

Don’t worry, git is complicated to everyone :slight_smile:

Do you have a local clone of the repo, on a Linux machine? Or are you working only from the GitHub website?

If you have a local Linux, please tell me what you get when you do

git remote -v

Thanks

Hi @pgr:

I have a local repo on windows and I’m working with NetBeans.

I use Git Desktop or Git CMD, when I go to the local folder and execute “git remote -v” I got:

origin  https://github.com/myuser/SuiteCRM.git (fetch)
origin  https://github.com/myuser/SuiteCRM.git (push)
upstream        https://github.com/salesagility/SuiteCRM.git (fetch)
upstream        https://github.com/salesagility/SuiteCRM.git (push)

Thanks,

David.

Ok, that setup looks correct, let’s try and fix things. You have your commit in master, which you shouldn’t have done.

  1. First, let’s bring your other branches up to date with upstream:

git fetch upstream

git checkout develop
git push origin develop --force

git checkout hotfix
git push origin hotfix --force

git checkout hotfix-7.8.x
git push origin hotfix-7.8-x --force

git checkout hotfix-7.9.x
git push origin hotfix-7.9-x --force
  1. You should do that to master also, but let’s not do it yet, since you have a commit in master that we want to grab. Let’s make a new sub-branch under develop, called feature-quotes, and put that commit in there.

git checkout develop
git checkout -b feature-quotes
git cherry-pick d9831685dd233ccf6b93abfe3f0ac537d4842712
git push origin feature-quotes
  1. Now check in GitHub if you have that sub-branch there with your new changes. When you do, you can update master on your origin from upstream.

  2. Now push all local branches up to origin

git push origin
  1. Finally, create a PR on GitHub from that new branch, into SalesAgility/develop. If everything went well there should be no conflicts, and no additional changes showing, apart from the ones in your development work.

After this is done I’ll tell you a few tips to do things more easily the next time.

Tell me how this goes

Hi @pgr and thanks for your guide.

I’ve done all in point number 1, but in number 2 I don’t understand what is:

git cherry-pick d9831685dd233ccf6b93abfe3f0ac537d4842712

Should I execute it as is or do I have to change something in the command?

Thanks

Yes, just do it like it is. It is referencing this:

https://github.com/davidbqzt/SuiteCRM/commit/d9831685dd233ccf6b93abfe3f0ac537d4842712

It basically grabs that one commit from master, and puts it in the current branch, which should be feature-quotes.

If I understand correctly, that contains all of the work that you meant to include in this PR, right?

1 Like

Hi @pgr,

I couldn’t complete the cherry-pick :frowning: I got a lot of errors, resolve some, but finally refuses without said why, I suspect that is because the first PR was on 7.9.x, but now we are on 7.10.1, but not sure, so I’ll rather start over with a new branch, do the development and then create a new PR or something like that.


D:\Users\Documents\NetBeansProjects\SuiteCRM>git status
On branch feature-quotes
nothing to commit, working tree clean

D:\Users\Documents\NetBeansProjects\SuiteCRM>git cherry-pick d9831685dd2
33ccf6b93abfe3f0ac537d4842712
Performing inexact rename detection: 100% (1160406/1160406), done.
error: could not apply d9831685d... Calculate list price according to cost and u
tility values
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

D:\Users\Documents\NetBeansProjects\SuiteCRM>

Anyway, thanks for the help.

David

You could resolve the conflicts and go ahead, but if you want to start fresh, this is the generic recipe:

  1. Bring the branch you want to edit up-to-date with upstream

  2. Start a new branch underneath that one, and do your changes there

  3. Commit often and then Push it up to origin when finished

  4. Do the Pull Request on GitHub

Hi pgr,

As I work on this new feature, I need a new dropdown list, I know that I can create dropdow or edit the existing on the Dropdown Editor, but…, as I’m developing a new feature, where or how should I create the new dropdown in order that it also be uploaded with the other changes.

Is there something like the vardefs file to create the dropdown or should I specify the structure of the dropdown when I make the pull request?

Thanks.

David.